Before proceeding i would recommend you to please go through a small tutorial. This tutorial will helps you to understand how text is displayed on graphical lcd, how graphical lcd dots are arranged in pages, how graphical lcd is initialized(Graphical Lcd initializing commands), each and every pin of graphical lcd is deeply explained in the tutorial. You can easily understand the code below if you go through the tutorial.
Graphical Lcd with Pic Microcontroller – Project requirements
- Microcontroller(Microchip Pic16f877)
- Graphical Lcd(JHD12864E)
- Crystal (20MHZ)
- Capacitors (30pf)
- Potentiometer-Variable resistor(0-100k)
- Connecting Wires
- Power Source (Battery, Adapter etc)
Graphical Lcd which i am using is JHD12864E. It comes in 20 Pin Package. Pin out of JHD12864E is given below. Its an 8-bit lcd. It comes with two built in controllers. Each controller is selected with chip select pins (cs1 and cs2). Visit the tutorial link given above to properly understand the pin functions and how to use them properly.
Graphical lcd with pic microcontroller – Project Circuit Diagram
All other connections are necessary connections to make controller work. Attach crystal(20Mhz) to controller in parallel to two 30pf capacitors. Supply +5v to vcc and vdd. Make GND ground. Circuit diagram of the project is give below.
- Clearlcd() function is half-filling each page with dots. Both halfs pages are filled in up and down position. If 2nd page of 1rst half is filled from down then 2nd page of 2nd half is filled from up.
- #define statements are defining pins as rs,rw,en etc. Now these pins can be accessed in code as rs,rw,en etc.
- delay() function is used to generate some delay where required.
- lcdcmd() is sending commands to lcd. It also manipulates lcd pins to successfully execute the command.
- lcddata() is sending data to lcd. It also manipulates lcd pins to successfully display data on lcd.
Main() function contains the code that displays all stuff on lcd. First it jumps to clearLcd() function fills pages with dots. Then it displays my web site name on lcd. Pattern of each character of my site is commented in the code.