LCD interfacing with 8051-II

YouTube link here LCD interfacing with 8051-II


Please find the coding below:

#include<regx51.h>
#define lcd P3            // define LCD DATA pins to Port-2
sbit RS = P2^0;          // Register select
sbit RW = P2^1;         // Read/write
sbit EN = P2^2;          // Enable pin
void delay (unsigned int ms)      // Delay function             
{
    unsigned int i, j;                                                       
    for (i=0; i<=ms; i++)
    for (j=0; j<1275; j++);                               
}
void lcd_cmd(unsigned char x)    //LCD command function
{
   lcd = x;
   RS = 0;
   RW = 0;
   EN = 1;
   delay(20);
   EN = 0;
}
void lcd_data(unsigned char t)    // LCD Data function
{
   lcd = t;
   RS = 1;
   RW = 0;
   EN = 1;
   delay(20);
   EN = 0;
}
void lcd_initial()                  //LCD initialization function
{
            lcd_cmd(0x38);        //Function set: 8-bit, 2-line 5x7 dots
            lcd_cmd(0x0c);        //Display ON, cursor OFF
            lcd_cmd(0x0E);        //Display ON, cursor ON
            lcd_cmd(0x01);        //Clear Display
}
           
void disp_str(unsigned char *p)        // Display String function
                                                           //*p is pointer variable
{
     for(*p=0;*p!='\0';*p++)
         {
           lcd_data(*p);
         }
}
void main()
{
/*int i = 0;
char ch;*/
            lcd_initial();
            disp_str("*** Hi Guys ***");
            lcd_initial();
            disp_str("Welcome to My");
            lcd_cmd(0xc0);                    //Cursor move from first line to second line
            delay(50);
            disp_str("Youtube channel");
            lcd_initial();
            disp_str("Please like this");
            lcd_cmd(0xc0);                   //Cursor move from first line to second line
            delay(50);
            disp_str("and Subscribe it");
            lcd_initial();
            disp_str("Thanks for watch");
            lcd_cmd(0xc0);                   //Cursor move from first line to second line
            delay(50);
            disp_str("**** Adios ****");
            delay(50);
    lcd_initial();
/*while(i < 10)
    {
    lcd_data("65");
    i++;
    delay(50);
}*/
            lcd_cmd(0x01);                  //Return Home
            lcd_cmd(0x0c);                  //Display ON cursor OFF*/
}

Thank You :)  

Comments

Popular posts from this blog

Interfacing 7 segment display with 8051

How to make robot car using 8051

Led Chaser using 8051