Omar Téllez
/
frdm_patrulla
torreta de patrulla y claxon
Fork of frdm_excercise7 by
main.cpp@1:83ed31fe1049, 2014-09-25 (annotated)
- Committer:
- OmarTellez
- Date:
- Thu Sep 25 19:21:05 2014 +0000
- Revision:
- 1:83ed31fe1049
- Parent:
- 0:2190998da98e
Patrulla;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rvazquezc | 0:2190998da98e | 1 | #include "mbed.h" |
rvazquezc | 0:2190998da98e | 2 | #define on 0 |
rvazquezc | 0:2190998da98e | 3 | #define off 1 |
rvazquezc | 0:2190998da98e | 4 | DigitalOut azul(LED_BLUE); |
rvazquezc | 0:2190998da98e | 5 | DigitalOut rojo(LED_RED); |
OmarTellez | 1:83ed31fe1049 | 6 | InterruptIn but(SW2); |
rvazquezc | 0:2190998da98e | 7 | DigitalOut verde(LED_GREEN); |
rvazquezc | 0:2190998da98e | 8 | void task(void); |
OmarTellez | 1:83ed31fe1049 | 9 | void task2 (void); |
rvazquezc | 0:2190998da98e | 10 | int main() |
rvazquezc | 0:2190998da98e | 11 | {azul=on; |
rvazquezc | 0:2190998da98e | 12 | rojo=off; |
OmarTellez | 1:83ed31fe1049 | 13 | verde=off; |
rvazquezc | 0:2190998da98e | 14 | while (true) { |
rvazquezc | 0:2190998da98e | 15 | azul=!azul; |
rvazquezc | 0:2190998da98e | 16 | rojo=!rojo; |
OmarTellez | 1:83ed31fe1049 | 17 | wait (0.5f); |
OmarTellez | 1:83ed31fe1049 | 18 | but.fall(&task); |
OmarTellez | 1:83ed31fe1049 | 19 | but.rise(task2); |
rvazquezc | 0:2190998da98e | 20 | } |
rvazquezc | 0:2190998da98e | 21 | } |
rvazquezc | 0:2190998da98e | 22 | void task() |
rvazquezc | 0:2190998da98e | 23 | {verde=on; |
OmarTellez | 1:83ed31fe1049 | 24 | } |
OmarTellez | 1:83ed31fe1049 | 25 | void task2() |
OmarTellez | 1:83ed31fe1049 | 26 | {verde=off; |
rvazquezc | 0:2190998da98e | 27 | } |