4 bit LCD interfacing with 8051







/*
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<reg51.h>
//#include"delay1s.h"
void Init_LCD(void);
void cmd_LCD(char cmd);
void display_LCD(char );
void write_LCD(char );
#define LCD P0
sbit RS=P0^0;
sbit RW=P0^1;
sbit EN=P0^2;
void delay()
{
int i;
TMOD=0X01;

for(i=0;i<=16;i++)
{
TR0=1;
while(!TF0);
TF0=0;
TR0=0;
}
}
main()
{
Init_LCD();
display_LCD('A');
}
void Init_LCD()
{
cmd_LCD(0x28);
cmd_LCD(0x0e);
cmd_LCD(0x01);
cmd_LCD(0x06);
cmd_LCD(0x80);
}
void cmd_LCD(char cmd)
{
LCD=(cmd&0xf0)|0x04; //0x20,en=1,rs=0
delay();
EN=0;
LCD=(cmd<<4)|0x04;  //0x80,en=1,rs=0
delay();
EN=0;
}
void display_LCD(char c)
{
LCD=(c&0xf0)|0x05; //en=1,rs=1
delay();
EN=0;
LCD=(c<<4)|0x05; //en=1,rs=1
delay();
EN=0;
}


SCHEMATIC



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