[TUT][C] LCD Tutorial 1001

21 posts / 0 new
Last post
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would tweak this code a bit by :

#define   LCD_DDR    DDRB // Or whatever...  
#define   LCD_DATA   PORTB //... names desired .

That way, if someone wanted to change to another port, or port it to another AVR and can't use PORTB, it'll be just 2 changes instead of 12 .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

indianajones11 wrote:
I would tweak this code a bit by :

#define   LCD_DDR    DDRB // Or whatever...  
#define   LCD_DATA   PORTB //... names desired .

That way, if someone wanted to change to another port, or port it to another AVR and can't use PORTB, it'll be just 2 changes instead of 12 .

"tweak"? Obviously you missed an important feature of Peter's code. All signals can be on different ports. Even the data lines don't need to be on the same port.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nope didn't miss that, but it would be good IF most or ALL are on the same port .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

but it would be good IF most or ALL are on the same port

Huh?!? In general, or in the specific case of using dannis code? He states as an explicit requirement that the case of pins being on different ports should be handled.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In my 1st post I should have wrote, "If one were to pick the same port for the 6 pins, ..." . Sorry about that .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As smiley said, works right out of the box ;) / Nailed it imo.

The love of something so annoying and complex is not love...Its a PASSION!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, what is busy testing means in this case ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are two methods for determining whether or not the LCD is ready for the next command. One is to delay long enough to know that the LCD has had time to process whatever it was doing. The other is to poll the LCDs busy flag. Busy testing refers to the second method.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello avr experts,

May I know how can I in anyway, modify danni's code above, to include the following :

double count =0, dist;
	delay_us(0.1);
	count=count+0.0000001;
	dist=count*34029/2;
        lcd_puts(dist); //i wish to display value of dist

dist= distance. I wish to display value of distance. but i know lcd_puts, puts out only character, in this case probably the character of distance's value. Instead of the chracter, I want to display the actual value in numbers of dist. May someone enlighten me on how to do this?
thank you very much.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lcd_putchar() takes a single character.
lcd_puts() takes a "string".

If you want to print a human readable number, you have to convert it to a string. Them you can output the string. Note that your string buffer must have enough room to hold the biggest number and its terminating NUL.

e.g. a 16-bit integer: "-32768" needs 7 bytes.
e.g. a 32-bit integer: "-2147483648" needs 12 bytes
e.g. a float or double: "1234.5678" or "-1.2345678e45" depend on the format.

You can use itoa(), utoa(), ftoa(), dtostrf(), ... and other non-standard functions.
There should always be sprintf() but many AVR compilers default to a 'small' sprintf() that may not handle floats or precision.

David.

Pages