Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HelloWorld by
Revision 2:e78cebb5a0d5, committed 2016-12-01
- Comitter:
- sumanshavi
- Date:
- Thu Dec 01 10:39:34 2016 +0000
- Parent:
- 1:03c191369089
- Child:
- 3:085dbf0f0726
- Commit message:
- motionsensor
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
motionsensor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Jan 01 20:57:57 2012 +0000 +++ b/main.cpp Thu Dec 01 10:39:34 2016 +0000 @@ -1,12 +1,20 @@ + #include "mbed.h" + +DigitalOut buzzer(p19); -DigitalOut myled(LED1); - -int main() { +DigitalIn motion(p29); + int main() { + + wait(2); //Wait for sensor to take snap shot of still room + while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + if (motion==0){ + buzzer=1; + wait(2); + } + else + buzzer=0; + } -} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motionsensor.h Thu Dec 01 10:39:34 2016 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" + +DigitalOut buzzer(p19); + +DigitalIn motion(p29); + int main() { + + wait(2); //Wait for sensor to take snap shot of still room + + while(1) { + if (motion==0){ + buzzer=1; + wait(2); + } + else + buzzer=0; + + } +} \ No newline at end of file