Simple 8 Bit 16x2 LCD Interfacing With PIC 16F: Jobs Electrician Usa
Simple 8 Bit 16x2 LCD Interfacing With PIC 16F: Jobs Electrician Usa
Simple 8 Bit 16x2 LCD Interfacing With PIC 16F: Jobs Electrician Usa
Page 1 of 6
REGISTER | LOGIN
GEEKS
FREE EBOOKS
TUTORIALS
FORUM
ONLINE TOOLS
USER PAGES
GAMES
IC Programmer+Adapter
Xeltek.com/ProgrammerAdapter-Saving Buy Xeltek Programmer & Adapter Together & Get Bundle Discount !
DaniWeb IT Community
www.daniweb.com Software Development Discussions Forums, Code Snippets, Tutorials
Pic RS232
I2C LCD
http://www.botskool.com/user-pages/tutorials/electronics/simple-8-bit-16x2-lcd-interfaci... 20-04-2013
Page 2 of 6
Control Signals
If RS=0 Instruction command Code register is selected, allowing user to send command RS=1 Data register is selected allowing to send data that has to be displayed.
R\W- Read\Write R\W input allows the user to write information to LCD or read information from it. How do we read data from LCD????? The data that is being currently displayed will be stored in a buffer memory DDRAM. This data could be read if necessary. If R\W=0 Reading R\W=1 Writing
E- Enable The enable Pin is used by the LCD to latch information at its data pins. When data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD to latch the data present in the data pins. E Toggle
Data Bus- D0-D7 Power for Backlighting LEDs VDDPower 5V Vss GND
General Explanation We have to prepare an LCD properly before the character we need, has to be displayed. For this a number of commands have to be provided to the LCD before inputting the required data. The commands will be discussed in the later part of this tutorial.
http://www.botskool.com/user-pages/tutorials/electronics/simple-8-bit-16x2-lcd-interfaci... 20-04-2013
Page 3 of 6
LCDdoesntknowaboutthecontent(dataorcommands)suppliedtoitsdatabus.Itistheuser whohastospecifywhetherthecontentatitsdatapinsaredataorcommands. Forthis,ifa commandisinputtedthenaparticularcombinationof0sand1shastobeappliedtotheControl linessoastospecifyitisaCommandontheotherhandifadataisinputtedatthedatalinesthen ananothercombinationof0sand1shastobeappliedtothecontrollinestospecifyitisData. (Hopeyouarenotconfused!!!!).Thecombinationsareasfollows If Command RS=0,R\W=0,E=1\0 Data RS=1,R\W=0,E=1\0
http://www.botskool.com/user-pages/tutorials/electronics/simple-8-bit-16x2-lcd-interfaci... 20-04-2013
Page 4 of 6
Programming Steps
Before sending Data to be Displayed to the LCD, it should be prepared to hold that particular value. For this certain initializations are to be done as per the Instructions. MoveValue0X38,3times.(Appliedmax3timesduetorisetimefactor) MoveValue0X06,1time. MoveValue0X0F,1time.
Aftereachinitializationscommandfunctionanddelayshouldbecalled.
AfterInitializationMoveDatatotheLCD
CalltheDataFunctionanddelay.
(2functions,oneforcommandandtheotherfordataisbeingwrittenforthesimplicityofthe program)
Program
#include"pic.h" #include"delay.h" void main() { void command(); //function for command manipolation void data(); //function for data manipulation int i; char a[ ]={"bOtskOOl-hari"}; TRISC=0X00; //Made Port C Out put port (to use with in main function) TRISB=0X00; //Made Port B output port (to use with outer function) DelayMs(1); PORTC=0X38; //to select the mode of the LED 0X38 - 8 bit 2 lines command(); // Call command function, shows that the given values are commands and not datas DelayMs(1); PORTC=0X38; //to select the mode of the LED 0X38 - 8 bit 2 lines command(); // Call command function DelayMs(1); PORTC=0X06; // to activate entry mode command(); DelayMs(1); PORTC=0X0F; //to get a blinking curser display command(); DelayMs(1); for(i=0;i<13;i++) { PORTC= a[i];
http://www.botskool.com/user-pages/tutorials/electronics/simple-8-bit-16x2-lcd-interfaci... 20-04-2013
Page 5 of 6
data(); //To show that the given values are data DelayMs(1); } while(1); }
void command() //command function definition { RB0=0; RB1=0; RB2=1; DelayUs(1); RB2=0; }
void data() //data function definition { RB0=1; RB1=0; RB2=1; DelayUs(1); RB2=0; }
HARI [email protected]
www.haripanangad.co.cc
Like 12 0 Recommend this on Google
http://www.botskool.com/user-pages/tutorials/electronics/simple-8-bit-16x2-lcd-interfaci... 20-04-2013
Page 6 of 6
Comments
Submitted by claudio1971 on Thu, 2012-12-13 19:53. Member since: 13 December 2012 Last activity: 18 weeks 15 hours Hi i try to write your code successfully , i want create my own application for lcd , i have just a question : how can i set line 2? you repeat just 2 times 0x38 but some display require 3 times , there is a reason for it? (to me work properly) Thank's :) claudio #1
Login or register to post comments Submitted by HARI on Sat, 2009-05-02 15:28. Member since: 10 March 2009 Last activity: 3 years 34 weeks Its HITECH PIC C #2
Login or register to post comments Submitted by shobhitkukreti on Sat, 2009-05-02 12:49. Member since: 28 April 2009 Last activity: 3 years 2 weeks Which compiler have you utilised ? #3
bOtskOOl website by bOtskOOl is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License. Permissions beyond the scope of this license may be available at http://www.botskool.com/contact. bOtskOOl.com Privacy Policy - bOt-Xchange Product Listing Policy - Intellectual Property Rights (IPR) Protection Policy
http://www.botskool.com/user-pages/tutorials/electronics/simple-8-bit-16x2-lcd-interfaci... 20-04-2013