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 #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 3:085dbf0f0726 11 if (motion==1){
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 }