temperature sensor application as a temperature based fan using the FRDM -K64F board
Fork of frdm_Grove_PIR_Example by
main.cpp@0:d444f103013a, 2015-12-31 (annotated)
- Committer:
- GregC
- Date:
- Thu Dec 31 23:29:45 2015 +0000
- Revision:
- 0:d444f103013a
- Child:
- 1:5c2fc62b9c0a
Freedom Seeed Grove PIR Example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregC | 0:d444f103013a | 1 | |
GregC | 0:d444f103013a | 2 | #include "mbed.h" |
GregC | 0:d444f103013a | 3 | |
GregC | 0:d444f103013a | 4 | InterruptIn motion(D2); |
GregC | 0:d444f103013a | 5 | |
GregC | 0:d444f103013a | 6 | int motion_detected = 0; |
GregC | 0:d444f103013a | 7 | |
GregC | 0:d444f103013a | 8 | void irq_handler(void) |
GregC | 0:d444f103013a | 9 | { |
GregC | 0:d444f103013a | 10 | motion_detected = 1; |
GregC | 0:d444f103013a | 11 | } |
GregC | 0:d444f103013a | 12 | |
GregC | 0:d444f103013a | 13 | int main(void) |
GregC | 0:d444f103013a | 14 | { |
GregC | 0:d444f103013a | 15 | int cnt = 0; |
GregC | 0:d444f103013a | 16 | motion.rise(&irq_handler); |
GregC | 0:d444f103013a | 17 | |
GregC | 0:d444f103013a | 18 | while(1) { |
GregC | 0:d444f103013a | 19 | if(motion_detected) { |
GregC | 0:d444f103013a | 20 | cnt++; |
GregC | 0:d444f103013a | 21 | motion_detected = 0; |
GregC | 0:d444f103013a | 22 | printf("Hello! I've detected %d times since reset\n", cnt); |
GregC | 0:d444f103013a | 23 | } |
GregC | 0:d444f103013a | 24 | } |
GregC | 0:d444f103013a | 25 | } |