ziad eldebri
/
pir_sensor
Expo2017_example
main.cpp
- Committer:
- ziadeldebri
- Date:
- 2017-05-14
- Revision:
- 0:493a823a2708
File content as of revision 0:493a823a2708:
#include "mbed.h" DigitalOut led1(LED2); DigitalIn alarm(PTB0, PullNone); //internal pull up PwmOut buzzer(PTE31); float freq[] = {659,554,659,554,440,494,554,587,494,659,554,400}; float beat[] = {1,1,1,1,1,0.5,0.5,1,1,1,1,2}; int main() { wait(2); //Wait for sensor to take snap shot of still room while(1) { if (alarm){ led1=0; for(int i = 0 ; i <= 4; i++){ buzzer.period(1/(2*freq[i])); buzzer = 0.5; wait(0.4*beat[i]); } } else { led1=1; buzzer = 0; } wait(1); } }