-
Notifications
You must be signed in to change notification settings - Fork 0
/
LPC2148 Code.c
66 lines (58 loc) · 1.28 KB
/
LPC2148 Code.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
#include<lpc214x.h>
#define bit(x) (1<<x)
#define delay for(i=0;i<7000;i++);
#define SOUND (IO1PIN & (1<<24))
unsigned int i;
void lcd_int();
void dat(unsigned char);
void cmd(unsigned char);
void string(unsigned char *);
void main()
{
IO0DIR =0XFFF;
IO1DIR = 0x0;
lcd_int();
cmd(0x80);
string("Group 12");
while(1) {
if(SOUND == 0) { //When the sound detection module detects a signal, Print in the LCD
string("Sound Detected");
}
delay;delay;
cmd(0x01);
}
}
void lcd_int()
{
cmd(0x38);
cmd(0x0c);
cmd(0x06);
cmd(0x01);
cmd(0x80);
}
void cmd(unsigned char a)
{
IO0PIN&=0x00;
IO0PIN|=(a<<0);
IO0CLR|=bit(8); //rs=0
IO0CLR|=bit(9); //rw=0
IO0SET|=bit(10); //en=1
delay;
IO0CLR|=bit(10); //en=0
}
void dat(unsigned char b)
{
IO0PIN&=0x00;
IO0PIN|=(b<<0);
IO0SET|=bit(8); //rs=1
IO0CLR|=bit(9); //rw=0
IO0SET|=bit(10); //en=1
delay;
IO0CLR|=bit(10); //en=0
}
void string(unsigned char *p)
{
while(*p!='\0') {
dat(*p++);
}
}