Tarea1-Versión3. Uso de 3 botones, al presionar el botón 1 el tiempo de encendido y apagado del LED disminuye, al presionar el botón 2 el tiempo de encendido y apagado del LED aumenta, al presionar el botón 3 se lleva el LED a un estado inicial (Reset)
Fork of Tarea1-V3 by
main.cpp@0:f8fe2133f19c, 2014-04-08 (annotated)
- Committer:
- juniorACA
- Date:
- Tue Apr 08 17:42:09 2014 +0000
- Revision:
- 0:f8fe2133f19c
Tarea1-V3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
juniorACA | 0:f8fe2133f19c | 1 | |
juniorACA | 0:f8fe2133f19c | 2 | #include "mbed.h" |
juniorACA | 0:f8fe2133f19c | 3 | #include "DebouncedIn.h" |
juniorACA | 0:f8fe2133f19c | 4 | |
juniorACA | 0:f8fe2133f19c | 5 | DebouncedIn puls1(PTC12); |
juniorACA | 0:f8fe2133f19c | 6 | DebouncedIn puls2(PTC13); |
juniorACA | 0:f8fe2133f19c | 7 | DebouncedIn puls3(PTC16); |
juniorACA | 0:f8fe2133f19c | 8 | DigitalOut myled(LED1); |
juniorACA | 0:f8fe2133f19c | 9 | |
juniorACA | 0:f8fe2133f19c | 10 | float k=0; |
juniorACA | 0:f8fe2133f19c | 11 | float t=0.01; |
juniorACA | 0:f8fe2133f19c | 12 | float r=0; |
juniorACA | 0:f8fe2133f19c | 13 | |
juniorACA | 0:f8fe2133f19c | 14 | int main() { |
juniorACA | 0:f8fe2133f19c | 15 | while(1) { |
juniorACA | 0:f8fe2133f19c | 16 | if(puls1.falling()){ |
juniorACA | 0:f8fe2133f19c | 17 | ++k; |
juniorACA | 0:f8fe2133f19c | 18 | t=0.01*(k*1.1); |
juniorACA | 0:f8fe2133f19c | 19 | } |
juniorACA | 0:f8fe2133f19c | 20 | myled = !myled; |
juniorACA | 0:f8fe2133f19c | 21 | wait(t); |
juniorACA | 0:f8fe2133f19c | 22 | if (puls2.falling()){ |
juniorACA | 0:f8fe2133f19c | 23 | --k; |
juniorACA | 0:f8fe2133f19c | 24 | t=0.01*(k*1.1);} |
juniorACA | 0:f8fe2133f19c | 25 | myled=!myled; |
juniorACA | 0:f8fe2133f19c | 26 | wait(t); |
juniorACA | 0:f8fe2133f19c | 27 | if(puls3.falling()){ |
juniorACA | 0:f8fe2133f19c | 28 | k=1; |
juniorACA | 0:f8fe2133f19c | 29 | t=0.01; |
juniorACA | 0:f8fe2133f19c | 30 | } |
juniorACA | 0:f8fe2133f19c | 31 | myled=!myled; |
juniorACA | 0:f8fe2133f19c | 32 | wait(t); |
juniorACA | 0:f8fe2133f19c | 33 | } |
juniorACA | 0:f8fe2133f19c | 34 | |
juniorACA | 0:f8fe2133f19c | 35 | } |
juniorACA | 0:f8fe2133f19c | 36 |