Hello ppls...new here to the forum.
I have a question about the LiquidCrystal coding.
In this statement below the order of the pins are selected how?
From "Hello World" ( four bit data )
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// select the pins used on the LCD panel
I have seen sketches where these pins are in different orders....kinda confusing.
What I'm asking I guess is there a defined order these should be in for the Arduino IDE to display?
(first pin declared=RS?,second pin=E?,3rd pin=data lsb?,4th pin=data lsb?,5th pin=data lsb?,6th pin=data msb?
Thanks in advance and sorry if posted in the wrong place.
Dale
(first pin declared=RS?,second pin=E?,3rd pin=data lsb?,4th pin=data lsb?,5th pin=data lsb?,6th pin=data msb?
That's it!
All it would take is a simple comment in the example program and your question would not have been needed.
Take a look at this forum thread from a week or so ago. The full explanation is in reply #4.
Don
But even better would be to use constant variables rather than naked pin numbers in the constructor.
i.e.:
// fill in aduino pin #s used to control LCD
const int rs=12; // arduino pin connect to LCD RS pin
const int en=11; // arduino pin connect to LCD Enable pin
const int d4=5; // arduino pin connected to LCD data bit 4 pin
const int d5=4; // arduino pin connected to LCD data bit 5 pin
const int d6=3; // arduino pin connected to LCD data bit 6 pin
const int d7=2; // arduino pin connected to LCD data bit 7 pin
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // constructor to initialize pins in library
This comes up enough that I think I'll create an issue to try to get them to update the examples.
What would you prefer for the variable names.
As above or perhaps LCDrs, LCDen, LCDd4, etc.... ??
I'll at least fix it in the examples that come with the hd44780 library.
(which already uses rs,en, and d4-d7)
--- bill
Bill:
Here we are going off topic for a change.
I typically use the same symbols as you (RS, E, D4, D5, D6, D7) except sometimes I use EN instead of E so that they are all the same length.
If you aren't concerned about keeping the length of all of the names the same then DB4, DB5, etc might be better than D4, D5, etc since (1) they match the terminology on the data sheet and (2) they are less likely to be mixed up with the Arduino 'digital' pin labels. Of course the addition of 'LCD' as in LCDd4 takes care of (2) as well.
As you are well aware I don't particularly care for the example in the tutorial. I suggest at least two examples. The first should just show how to display two lines of text in setup() with loop() empty. The second could be based on the present example but the second line should have some fixed text as well as the changing count. That would illustrate how the fixed characters are displayed in setup() and the changing ones are displayed in loop().
A third example could have a decreasing counter to illustrate how to get rid of vestigial characters.
I guess I should look at your examples, maybe you already took care of all this.
Don