Nora Vazbyte
/
PIR_Sensor_HelloWorld
Working PIR sensor
main.cpp@0:61201dd6e178, 2015-03-05 (annotated)
- Committer:
- awood37
- Date:
- Thu Mar 05 23:08:46 2015 +0000
- Revision:
- 0:61201dd6e178
- Child:
- 1:f6f524d2dc18
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
awood37 | 0:61201dd6e178 | 1 | #include "mbed.h" |
awood37 | 0:61201dd6e178 | 2 | |
awood37 | 0:61201dd6e178 | 3 | DigitalOut led1(LED1); |
awood37 | 0:61201dd6e178 | 4 | DigitalIn alarm(p29, PullUp); //internal pull up |
awood37 | 0:61201dd6e178 | 5 | |
awood37 | 0:61201dd6e178 | 6 | int main() { |
awood37 | 0:61201dd6e178 | 7 | wait(2); //Wait for sensor to take snap shot of still room |
awood37 | 0:61201dd6e178 | 8 | |
awood37 | 0:61201dd6e178 | 9 | while(1) { |
awood37 | 0:61201dd6e178 | 10 | if (!alarm){ |
awood37 | 0:61201dd6e178 | 11 | led1=1; |
awood37 | 0:61201dd6e178 | 12 | wait(2); |
awood37 | 0:61201dd6e178 | 13 | } |
awood37 | 0:61201dd6e178 | 14 | else |
awood37 | 0:61201dd6e178 | 15 | led1=0; |
awood37 | 0:61201dd6e178 | 16 | } |
awood37 | 0:61201dd6e178 | 17 | } |