Home > other >  To be a human body induction alarm, using infrared sensor (HC_SR501) and a buzzer, based on CC2530,
To be a human body induction alarm, using infrared sensor (HC_SR501) and a buzzer, based on CC2530,

Time:10-09

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* name said InitGpio ()
* can work: set the LED lights and P0.4 corresponding IO mouth
No
* entrance parameters:No
* export parameters:* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void InitLed (void)
{
P1DIR |=0 x13;//P1.0, P1.1, P1.4 defined as output
P0SEL & amp;=0 x10 ~;
P0DIR & amp;=0 x10 ~;//P0.4 is defined as the input port
P2INP |=0 x20;

LED2=0;//light D2 prompt program has been running
}
Void main (void)
{
InitLed ();//set the LED lights and P0.4 corresponding IO mouth
InitUart ();//set serial port a related register
CLKCONCMD & amp;=~ 0 x40;//set the system clock source for 32 MHZ crystals
While (CLKCONSTA & amp; 0 x40);//wait for stable crystals to 32 m
CLKCONCMD & amp;=~ 0 x47;//set the system master clock frequency is 32 MHZ

InitUart ();//set serial port a related register

While (1)//infinite loop
{
If (DATA_PIN==1)
{
LED1=0;//when someone LED1 light
UartSendString (" ON ", 3);//a serial port to send data, prompt the user
}
The else
{
LED1=1;//no man LED1 out
UartSendString (" OFF ", 4);//a serial port to send data, prompt the user
}

DelayMS (1000);
}
}

CodePudding user response:

An increase in an ultrasonic ranging, the closer distance voice

CodePudding user response:

Coupled with a serial port turn 4 g invasion detected is sent text messages to you, do you want to be complicated or easy

CodePudding user response:

Add control terminals such as display password management
  • Related