Gopikrissh
Newbie level 5
Can anyone tell me how to ring a buzzer in lpc2148 using embedded c program???
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Can anyone tell me how to ring a buzzer in lpc2148 using embedded c program???
Code C - [expand] 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 ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||; ;|| ||; ;|| Title : Buzzer.c ||; ;|| Status : Completed! ||; ;|| Features : ON/Off buzzer with time delay intervals ||; ;|| Description : Buzzer Port : P0.7 ||; ;|| Oscillator : 12MHz ||; ;|| Enable Buzzer, Put Jumper JP1 to 'E' Mode. ||; ;|| ||; ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||; /***********************************************************************************************/ //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< DIRECTIVES >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #include <LPC214x.h> #include <stdio.h> #define BUZZ 7 void Delay(void); void Wait(void); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Code Begins Here >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void Delay() { unsigned int i,j; for(i=0;i<1000;i++) for(j=0;j<700;j++); } void main() { PINSEL0 = 0x00; //Configure Port0.7 as GPIO IODIR0 = 3 << BUZZ; //Configure Port0.7 as OutPut pin while(1) { IOSET0 = 1 << BUZZ; Delay(); IOCLR0 = 1 << BUZZ; Delay(); } }
#include <lpc213x.h>
int main(void)
{
PINSEL0 = 0X00000000;
IO0DIR |= (1<<0);
while(1)
{
if (IO0PIN & 0X00000080)
{
IO0SET |= 0X00000001;
}
else IO0CLR |= 0X00000001;
}
}
#include <lpc213x.h>
int main(void)
{
PINSEL0 &= 0X00000000;
IO0DIR = 0X00000000; //SWITCH P0.7
IO0DIR |= 0X01; //LED P0.0
while(1)
{
if ((IO0PIN & 0x80) == 0)
{
IO0CLR |= (1<<0);
}
else IO0SET |= (1<<0);
}
}
[ATTACH=CONFIG]76537._xfImport[/ATTACH]