Nora Vazbyte
/
PIR_Sensor_HelloWorld
Working PIR sensor
main.cpp@1:f6f524d2dc18, 2019-01-31 (annotated)
- Committer:
- vazbyte
- Date:
- Thu Jan 31 17:19:30 2019 +0000
- Revision:
- 1:f6f524d2dc18
- Parent:
- 0:61201dd6e178
- Child:
- 2:7844d0880ba7
working though slowly
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
awood37 | 0:61201dd6e178 | 1 | #include "mbed.h" |
vazbyte | 1:f6f524d2dc18 | 2 | |
awood37 | 0:61201dd6e178 | 3 | DigitalOut led1(LED1); |
vazbyte | 1:f6f524d2dc18 | 4 | DigitalIn alarm(p29, PullNone); //internal pull up |
vazbyte | 1:f6f524d2dc18 | 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 | } |