LCD introduction
LCD’s i.e, Liquid Crystal Displays utilize two sheets of polarizing material with a liquid crystal solution between them. An electric current passed through the liquid causes the crystals to align so that light cannot pass through them. Each, crystal, therefore, is like a shutter, either allowing light to pass through or blocking the light. The most commonly used alphanumeric displays are 1x16 (single line and 16 characters), 2x16 (double line and 16 characters per line) and 4x20 (four lines and twenty characters per line).
- pin 1 - vss - ground
- pin2 - vdd - supply voltage
- pin3 - vc - contrast setting
- pin4 - rs - register select
- pin5 - r/w - read/write select
- pin6 - en - chip enable signal
- pin7 to pin 14 - DB0 to DB7 - data lines
- pin 15 - vcc for backlight
- pin16 - gnd for backlight
When R/W is low (logic 0), the information on the data bus is being written to the LCD. When R/W is high (logic 1), the program is effectively reading from the LCD. Most of the times there is no need to read data from the LCD so this line can directly be connected to GND thus saving one controller line.
The EN pin is used to latch the data present on the data pins. A HIGH to LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed.
Display Data Ram (DDRAM) stores the display data. So when we have to display a character on LCD we basically write it into DDRAM. For a 2x16 LCD the DDRAM address for first line is from 80h to 8fh and for second line is 0c0h to 0cfh. So if we want to display 'H' on the 7th position pf the first line then we will write it at location 87h.