16F LCD Example
Basic takes the stress completely out of
LCD interfacing, the only
concern is that you get the Pin-out right.
LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4
LCD_LINES = 2
LCD_TYPE = 0
This is
setting the Pin PORTB.2 to the RS Pin on the
LCD and the EN Pin to
PORTB.3 etc..
My programs that use
LCD's may have a different Pin-outs to
what you use/what your default in your .INC file is that you include
in your program. I use the above information for Pin-outs, and
wiring the
LCD is as follows;

Note the PIC's power supply/oscillator are not shown
Click
here too see this circuit in action!
To make life even easier, you can solder
pins to the
LCD so that you can just 'insert' it into your
breadboard

The Vo is the
contrast setting, if your
LCD doesn't
appear to be working, chances are that the contrast setting is
incorrect, adjust the contrast when you have no data/PIC connected
to it, and you should see blocks across the 1st line,
don't make
it to dark, or you will not see any change from the dark blocks.
Alternatively, double check your wiring and then in your program
send out some info like Print At 1,1, "Hello World" and
adjust the contrast until you can clearly read it.
One thing to remember about
LCD's is to give them ~100-200ms to
power-up. They run through their own initialization, and if you
were to send data to it immediately, nothing would be displayed.
Basic
initialization code to include in your program for
LCD support would
be:
LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4
LCD_LINES = 2
LCD_TYPE = 0
Delayms 150
Cls
The command CLS takes time to perform on the
LCD. Some
compilers include a small delay by default as part of the
CLS command, read up on it in the help file, if it doesn't,
include a small delay ~10ms.
And a
basic example of how to display data on the
LCD;
Device = 16F877
XTAL = 4
LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4
LCD_LINES = 2
LCD_TYPE = 0
ALL_DIGITAL = True
Delayms 150
Cls
Main:
Print At 1,1, "Hello World"
While 1=1 ' Loop for ever
Wend
Where you can get the components;

 | Site Tutorial Index |
|  | 16F PIC Examples |
| |  | Motors |
| |  | Thermometers |
| |  | Code Snippets |
|  | 18F PIC Examples |
|  | Handy Tips |