forked from RAMSIVARAJ/KCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCD.c
82 lines (73 loc) · 830 Bytes
/
LCD.c
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <AT89S52.h>
#define DATA P2
#define RS P3_0
#define EN P3_2
#define RW P3_1
void lcd_init(void);
void lcd_data(char);
void lcd_cmd(char);
void lcd_busy(void);
void lcd_print(char*);
void main()
{
EN=0;
lcd_init();
lcd_print("Welcome to");
lcd_cmd(0xC0);
lcd_print("KCE - ECE Dept.");
while(1)
{
//lcd_cmd(0x1C);
}
}
void lcd_init(void)
{
lcd_busy();
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x0C);
lcd_cmd(0x06);
lcd_cmd(0x80);
}
void lcd_cmd(char c)
{
DATA=c;
RS=0;
RW=0;
EN=1;
EN=0;
lcd_busy();
}
void lcd_data(char d)
{
DATA=d;
RS=1;
RW=0;
EN=1;
EN=0;
lcd_busy();
}
void lcd_busy()
{
char s;
RS=0;
RW=1;
DATA=0xFF;
EN=1;
s=DATA&0x80;
EN=0;
while(s!=0x00)
{
EN=1;
s=DATA&0x80;
EN=0;
}
}
void lcd_print(char*msg)
{
while(*msg!=0x00)
{
lcd_data(*msg);
*msg++;
}
}