Gustavo Ramirez
/
tresleds
programa que hace uso de puertos de salida
main.cpp@0:d4271fb85f3d, 2013-09-06 (annotated)
- Committer:
- tony63
- Date:
- Fri Sep 06 16:02:38 2013 +0000
- Revision:
- 0:d4271fb85f3d
programa que activa leds rgb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tony63 | 0:d4271fb85f3d | 1 | #include "mbed.h" |
tony63 | 0:d4271fb85f3d | 2 | |
tony63 | 0:d4271fb85f3d | 3 | DigitalOut leds[] = {(LED1), (LED2),(LED3)}; /*configuro los puertos asignados al led rgb */ |
tony63 | 0:d4271fb85f3d | 4 | |
tony63 | 0:d4271fb85f3d | 5 | int main() { |
tony63 | 0:d4271fb85f3d | 6 | int i, previous; /*declaro dos variables */ |
tony63 | 0:d4271fb85f3d | 7 | int numLeds = sizeof(leds)/sizeof(DigitalOut);/*sizeof operador de tiempo de compilacion */ |
tony63 | 0:d4271fb85f3d | 8 | while(1) { |
tony63 | 0:d4271fb85f3d | 9 | for (i = 0; i < numLeds; i++){ |
tony63 | 0:d4271fb85f3d | 10 | if (i == 0) previous = (numLeds - 1); |
tony63 | 0:d4271fb85f3d | 11 | else previous = i - 1; |
tony63 | 0:d4271fb85f3d | 12 | |
tony63 | 0:d4271fb85f3d | 13 | leds[i] = 1; |
tony63 | 0:d4271fb85f3d | 14 | leds[previous] = 0; |
tony63 | 0:d4271fb85f3d | 15 | |
tony63 | 0:d4271fb85f3d | 16 | wait(0.2); |
tony63 | 0:d4271fb85f3d | 17 | } |
tony63 | 0:d4271fb85f3d | 18 | } |
tony63 | 0:d4271fb85f3d | 19 | } |