motion sensor is used to detect the any object

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

Committer:
sumanshavi
Date:
Thu Dec 01 10:45:55 2016 +0000
Revision:
3:085dbf0f0726
Parent:
2:e78cebb5a0d5
motion sensor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sumanshavi 2:e78cebb5a0d5 1
simon 0:fb6bbc10ffa0 2 #include "mbed.h"
sumanshavi 2:e78cebb5a0d5 3
sumanshavi 2:e78cebb5a0d5 4 DigitalOut buzzer(p19);
simon 0:fb6bbc10ffa0 5
sumanshavi 2:e78cebb5a0d5 6 DigitalIn motion(p29);
sumanshavi 2:e78cebb5a0d5 7 int main() {
sumanshavi 2:e78cebb5a0d5 8
sumanshavi 2:e78cebb5a0d5 9 wait(2); //Wait for sensor to take snap shot of still room
sumanshavi 2:e78cebb5a0d5 10
simon 0:fb6bbc10ffa0 11 while(1) {
sumanshavi 3:085dbf0f0726 12 if (motion==1){
sumanshavi 2:e78cebb5a0d5 13 buzzer=1;
sumanshavi 2:e78cebb5a0d5 14 wait(2);
sumanshavi 2:e78cebb5a0d5 15 }
sumanshavi 2:e78cebb5a0d5 16 else
sumanshavi 2:e78cebb5a0d5 17 buzzer=0;
sumanshavi 2:e78cebb5a0d5 18
simon 0:fb6bbc10ffa0 19 }
sumanshavi 2:e78cebb5a0d5 20 }