ziad eldebri
/
pir_sensor
Expo2017_example
Revision 0:493a823a2708, committed 2017-05-14
- Comitter:
- ziadeldebri
- Date:
- Sun May 14 20:14:10 2017 +0000
- Commit message:
- Expo2017;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun May 14 20:14:10 2017 +0000 @@ -0,0 +1,30 @@ +#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); + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun May 14 20:14:10 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6 \ No newline at end of file