Augusto Panecatl
/
Interrupt_RGB
Interrupt code example for FRDM-KL25Z
main.cpp@0:e1052d370745, 2014-06-04 (annotated)
- Committer:
- APanecatl
- Date:
- Wed Jun 04 19:24:45 2014 +0000
- Revision:
- 0:e1052d370745
Rev 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
APanecatl | 0:e1052d370745 | 1 | #include "mbed.h" |
APanecatl | 0:e1052d370745 | 2 | |
APanecatl | 0:e1052d370745 | 3 | |
APanecatl | 0:e1052d370745 | 4 | DigitalOut RED(LED1); |
APanecatl | 0:e1052d370745 | 5 | DigitalOut BLUE(LED2); |
APanecatl | 0:e1052d370745 | 6 | InterruptIn Interrupt(PTD1); |
APanecatl | 0:e1052d370745 | 7 | |
APanecatl | 0:e1052d370745 | 8 | |
APanecatl | 0:e1052d370745 | 9 | void blink() |
APanecatl | 0:e1052d370745 | 10 | { |
APanecatl | 0:e1052d370745 | 11 | RED=1; |
APanecatl | 0:e1052d370745 | 12 | BLUE=0; |
APanecatl | 0:e1052d370745 | 13 | wait(.4); |
APanecatl | 0:e1052d370745 | 14 | BLUE=1; |
APanecatl | 0:e1052d370745 | 15 | wait(.4); |
APanecatl | 0:e1052d370745 | 16 | } |
APanecatl | 0:e1052d370745 | 17 | |
APanecatl | 0:e1052d370745 | 18 | int main() |
APanecatl | 0:e1052d370745 | 19 | { |
APanecatl | 0:e1052d370745 | 20 | Interrupt.fall(&blink); |
APanecatl | 0:e1052d370745 | 21 | |
APanecatl | 0:e1052d370745 | 22 | BLUE=1; |
APanecatl | 0:e1052d370745 | 23 | while (1) |
APanecatl | 0:e1052d370745 | 24 | { |
APanecatl | 0:e1052d370745 | 25 | RED=0; |
APanecatl | 0:e1052d370745 | 26 | } |
APanecatl | 0:e1052d370745 | 27 | |
APanecatl | 0:e1052d370745 | 28 | } |