-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
72 lines (63 loc) · 972 Bytes
/
main.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
#include<reg51.h>
#define lcd P3
sbit FLAME=P1^0;
sbit rs=P2^0; //register select
sbit rw=P2^1; //RW
sbit en=P2^2; //enable
void lcd_init();
void cmd(unsigned char);
void dat(unsigned char);
void delay();
void lcd_string(char *s);
void main()
{
lcd_init();
lcd_string(" Fire Detected System ");
while(1) {
if(FLAME) {
cmd(0xc0);
lcd_string("Flame Detected");
delay();
} else {
cmd(0xc0);
lcd_string(" No Flame Detected ");
}
}
}
void lcd_init()
{
cmd(0x38);
cmd(0x0e);
cmd(0x06);
cmd(0x01);
cmd(0x80);
}
void cmd(unsigned char a)
{
lcd=a;
rs=0;
rw=0;
en=1;
delay();
en=0;
}
void dat(unsigned char b)
{
lcd=b;
rs=1;
rw=0;
en=1;
delay();
en=0;
}
void lcd_string(char *s)
{
while(*s) {
dat(*s++);
}
}
void delay()
{
unsigned int i;
for(i=0;i<20000;i++);
}