motion sensor is used to detect the any object
Fork of HelloWorld by
motionsensor.h@2:e78cebb5a0d5, 2016-12-01 (annotated)
- Committer:
- sumanshavi
- Date:
- Thu Dec 01 10:39:34 2016 +0000
- Revision:
- 2:e78cebb5a0d5
- Child:
- 3:085dbf0f0726
motionsensor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sumanshavi | 2:e78cebb5a0d5 | 1 | #include "mbed.h" |
sumanshavi | 2:e78cebb5a0d5 | 2 | |
sumanshavi | 2:e78cebb5a0d5 | 3 | DigitalOut buzzer(p19); |
sumanshavi | 2:e78cebb5a0d5 | 4 | |
sumanshavi | 2:e78cebb5a0d5 | 5 | DigitalIn motion(p29); |
sumanshavi | 2:e78cebb5a0d5 | 6 | int main() { |
sumanshavi | 2:e78cebb5a0d5 | 7 | |
sumanshavi | 2:e78cebb5a0d5 | 8 | wait(2); //Wait for sensor to take snap shot of still room |
sumanshavi | 2:e78cebb5a0d5 | 9 | |
sumanshavi | 2:e78cebb5a0d5 | 10 | while(1) { |
sumanshavi | 2:e78cebb5a0d5 | 11 | if (motion==0){ |
sumanshavi | 2:e78cebb5a0d5 | 12 | buzzer=1; |
sumanshavi | 2:e78cebb5a0d5 | 13 | wait(2); |
sumanshavi | 2:e78cebb5a0d5 | 14 | } |
sumanshavi | 2:e78cebb5a0d5 | 15 | else |
sumanshavi | 2:e78cebb5a0d5 | 16 | buzzer=0; |
sumanshavi | 2:e78cebb5a0d5 | 17 | |
sumanshavi | 2:e78cebb5a0d5 | 18 | } |
sumanshavi | 2:e78cebb5a0d5 | 19 | } |