LCD sample program

LCD sample program


/*
developed by S4silver
license type - open source
created on - 11/12/2014
modified on - 11/14/2014
modification details - refactored
developer - Frank Hust Jincson
contact mail id - silverembeddedsolutions@gmail.com
web link - http://s4silver.blogspot.in/p/programmers-colony.html
*/

#include <REGX51.H>
sbit RS = P3^6;
sbit EN = P3^7;

void delay(unsigned char del)
{
 unsigned int i,j;
 for(i=0;i<del;i++)
  for(j=0;j<200;j++);
}

void lcd_cmd(unsigned char cmd)
{
 P1 = cmd;
 RS=0;
 EN=1;
 delay(2);
 EN=0;
}

void lcd_data(unsigned char dat)
{
 P1 = dat;
 RS=1;
 EN=1;
 delay(2);
 EN=0;
}

int main()
{
 unsigned int i;
 unsigned char c;
 SCON=0x50;
 TMOD=0x20;
 TH1=-6;     // 0xFD=253      9600
 TR1=1;

 P1=0x00;
 RS=0;
 EN=0;

 lcd_cmd(0x38);       // 2 line 8 bit mode     
 lcd_cmd(0x01);  // Reset LCD Display
 lcd_cmd(0x06);  // Shift Display Right
 lcd_cmd(0x0C);  // Display ON cursor Blinking

 lcd_cmd(0x80);       // First Line First Display
 lcd_data('A');
 SBUF='A';
 while(!TI);
 TI=0;

 while(1)
 {
  while(RI==0);
  c=SBUF;
  RI=0;

  lcd_cmd(0x82);
  lcd_data(c);

 }
}




People who look for this also look for the below topics

blinking of led or port
8051 interfacing DC motor
8051 interfacing with keypad
8051 interfacing with LCD
8051 interfacing with LCD and display Counter
LCD sample program
serial communication (RS-232) in 8051(polling method)
serial with interrupt
how to print serial received data on LCD.
8051 interfacing STEPPER motor
how to use TIMER in 8051
8051 interfacing SEVEN SEGMENT display
Timers with interrupt concept
how to generate PWM in 8051
4 bit LCD interfacing with 8051
8051 Tuitorial
how to install python
Embedded Documents (sensors, protocol...etc)  
Special NEWS

No comments:

Post a Comment