Skip to content

Commit 0ff8c5b

Browse files
authored
Add files via upload
1 parent 45b1e48 commit 0ff8c5b

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

LCD_Interface/LCD.c

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//CODE FOR LCD INTERFACING WITH IC 8051 MICROCONTROLLER USING PROTEUS.
2+
3+
#include<reg52.h>
4+
5+
// RS RW E D0 - D7
6+
// P2.0 P2.1 P2.2 P1.0 - P1.7
7+
//#defining conections with port 2 pins
8+
sbit RS=P2^0;// means RS = P2.0 pin
9+
sbit RW=P2^1;
10+
sbit E=P2^2;
11+
12+
// user defined functions
13+
void send_command(unsigned int command_value ) ;
14+
void send_data(unsigned int data_value) ; // function for passing data
15+
void ms_delay( unsigned int time); // function for delay window
16+
17+
void main()
18+
{
19+
20+
//LCD INITIALIZATION
21+
22+
//2 lines and 5x7 matrix
23+
send_command(0x38); // giving command to LCD (writting into command code register of LCD)
24+
25+
//display on cursor blink
26+
send_command(0x0E);
27+
28+
//clear display screen
29+
send_command(0X01);
30+
31+
32+
33+
34+
//PRINTING A CHARACTER
35+
36+
while(1)
37+
{
38+
39+
send_command(0x80) ; // force cursor on 1st line
40+
send_data('H');
41+
send_data('E');
42+
send_data('L');
43+
send_data('L');
44+
send_data('O');
45+
46+
47+
send_command(0xC0) ; // force cursor on 2nd line
48+
49+
send_data('W');
50+
send_data('O');
51+
send_data('R');
52+
send_data('L');
53+
send_data('D');
54+
}
55+
56+
}
57+
58+
// defining functions
59+
60+
void send_command(unsigned int command_value ) // used to send command to Instruction Command Code Register
61+
{
62+
P1=command_value; // write data to port pins
63+
RW=0; // RW=0 to write data and RW=1 to read data
64+
RS=0; // RS(register select )=0 to select instruction command code reg.
65+
E=1; // enable pin at active High
66+
ms_delay(10);
67+
E=0;
68+
}
69+
// after this the data present at port pins will latch(be present) in the command code register of LCD
70+
71+
void send_data(unsigned int data_value) // used to send data to Data Register
72+
{
73+
P1=data_value;
74+
RW=0;
75+
RS=1; //RS(register select )=1 to select Data reg.
76+
E=1;
77+
ms_delay(10);
78+
E=0;
79+
}
80+
// after this the data present at port pins will latch(be present) in the Data register of LCD
81+
82+
83+
void ms_delay( unsigned int time)
84+
{
85+
unsigned int i,j;
86+
//time X 1ms
87+
for(i=0;i<time;i++)
88+
{
89+
for(j=0;j<113;j++); //1 ms delay
90+
}
91+
}
92+

LCD_Interface/LCD_ckt.png

71 KB
Loading

0 commit comments

Comments
 (0)