-
Notifications
You must be signed in to change notification settings - Fork 0
/
FireAlert11.c
77 lines (70 loc) · 984 Bytes
/
FireAlert11.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
#include<reg51.h>
sbit sensor = P1^0;
sbit rs = P1^1;
sbit rw = P1^2;
sbit en = P1^3;
sbit buzzer = P3^0;
void lcdinit();
void lcddat(unsigned char);
void lcdcmd(unsigned char);
void lcddis(unsigned char *);
void delay();
void main()
{
buzzer=0;
sensor=0;
back: lcdinit();
lcddis(" FIRE ALERT ");
lcdcmd(0xc0);
lcddis(" SYSTEM ");
delay();
while(1)
{
if(sensor==1)
{
lcdcmd(0x01);
lcddis("FIRE OCCURED");
buzzer=1;
}
goto back;
}
}
void lcdinit()
{
lcdcmd(0x38);
lcdcmd(0x01);
lcdcmd(0x10);
lcdcmd(0x0c);
lcdcmd(0x80);
}
void lcdcmd(unsigned char val)
{
P2=val;
rs=0;
rw=0;
en=1;
delay();
en=0;
}
void lcddat(unsigned char dat)
{
P2=dat;
rs=1;
rw=0;
en=1;
delay();
en=0;
}
void lcddis(unsigned char *s)
{
unsigned char w;
for(w=0;s[w]!='\0';w++)
{
lcddat(s[w]);
}
}
void delay()
{
unsigned int v1;
for(v1=0;v1<10000;v1++);
}