Laxman Kumar
Junior Member level 1
I am using P89V51RD2 microcontroller and trying to interface with 16x2 LCD (jhd162a)...but not able to get a single character on LCD...
here is the code i am using...what is the problem....
----------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
here is the code i am using...what is the problem....
----------------------------------------------------------------------------------------------------------
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 #include<reg51.h> // include header file #define msec 50 // definition for delay sbit rs=P3^0; //Register select (RS) sbit rw=P3^1; //Read write (RW) pin sbit en=P3^6; //Enable (EN) pin unsigned char commands[]={0x38,0x0E,0x01,0x06,'\0'}; //Command to be sent to LCD (initializing) char name[]={"microcontroller 8051"}; //String to be displayed on LCD void delay(unsigned int time) //Time delay function { unsigned int i,j; for(i=0;i<time;i++) for(j=0;j<1275;j++); } void lcdcmd(unsigned char value) //Function for sending values to the command register of LCD { P2=value; rs=0; rw=0; en=1; delay(1); en=0; return; } void display(unsigned char value) //Function for sending values to the data register of LCD { P2=value; rs=1; rw=0; en=1; delay(1); en=0; return; } void main() { int i,j; for(i=0;commands[i]!='\0';i++) //Sending string to LCD { lcdcmd(commands[i]); delay(msec); } for(j=0;name[j]!='\0';j++) { display(name[j]); delay(msec); } while(1) { lcdcmd(0x18); //Shift the entire display to right delay(75); } }
------------------------------------------------------------------------------------------
Last edited by a moderator: