Buzzer

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1: #include <LPC21xx.

h>
2: //#include "Timer0.h"
3: unsigned int delay=0;
4:
5: /*int main ()
6: {
7: IO0DIR = 0x00000200 ; //Set P0.18(RLY1) and P0.19(RLY2) as output
8: PINSEL0= 0X00000000;
9: while(1)
10: {
11: IO0SET= 0x00000200; //set high one port line
12: for(delay=0;delay<1111111;delay++); //delay
13: IO0CLR = 0x00000200; //set low one port line
14: for(delay = 0; delay<1111111;delay++); //delay
15:
16: }
17: } */
18:
19:
20:
21: int main ()
22: {
23: InitTimer0(0);
24: IO0DIR = 0x00000200 ; // Configure P0.9 as output
25:
26: while(1)
27: {
28: //Generating a pulse train of 1 KHz using Timer
29: IO0SET = 0x00000200 ; //Buzzer ON
30: for(delay=0;delay<100000;delay++);
31: // DelayMs (1);
32: IO0CLR = 0x00000200 ; //Buzzer OFF
33: for(delay=0;delay<100000;delay++);
34: // DelayMs (1);
35: }
36: }
37:

You might also like