Rikiya Yamamoto
/
mbed_blinky_LPC1114
mbed_blinky_LPC1114
Fork of mbed_blinky by
main.cpp@7:f43f82ebd32a, 2015-03-23 (annotated)
- Committer:
- rkyymmt
- Date:
- Mon Mar 23 03:31:08 2015 +0000
- Revision:
- 7:f43f82ebd32a
- Parent:
- 4:81cea7a352b0
init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan | 0:7dec7e9ac085 | 1 | #include "mbed.h" |
dan | 0:7dec7e9ac085 | 2 | |
rkyymmt | 7:f43f82ebd32a | 3 | DigitalOut leds[] = {dp1, dp2, dp4, dp6, dp9, dp10, dp11, dp13, dp14}; |
rkyymmt | 7:f43f82ebd32a | 4 | int numLeds = sizeof(leds)/sizeof(DigitalOut); |
dan | 0:7dec7e9ac085 | 5 | |
dan | 0:7dec7e9ac085 | 6 | int main() { |
rkyymmt | 7:f43f82ebd32a | 7 | double w_time = 0.05; |
dan | 0:7dec7e9ac085 | 8 | while(1) { |
rkyymmt | 7:f43f82ebd32a | 9 | for (int previous, i = 0; i < numLeds; i++){ |
rkyymmt | 7:f43f82ebd32a | 10 | if (i == 0) previous = (numLeds - 1); |
rkyymmt | 7:f43f82ebd32a | 11 | else previous = i - 1; |
rkyymmt | 7:f43f82ebd32a | 12 | leds[i] = 1; |
rkyymmt | 7:f43f82ebd32a | 13 | leds[previous] = 0; |
rkyymmt | 7:f43f82ebd32a | 14 | wait(w_time); |
rkyymmt | 7:f43f82ebd32a | 15 | } |
rkyymmt | 7:f43f82ebd32a | 16 | for (int previous, i = numLeds - 1; i > 0; i--){ |
rkyymmt | 7:f43f82ebd32a | 17 | if (i == 0) previous = (numLeds - 1); |
rkyymmt | 7:f43f82ebd32a | 18 | else previous = i + 1; |
rkyymmt | 7:f43f82ebd32a | 19 | leds[i] = 1; |
rkyymmt | 7:f43f82ebd32a | 20 | leds[previous] = 0; |
rkyymmt | 7:f43f82ebd32a | 21 | wait(w_time); |
rkyymmt | 7:f43f82ebd32a | 22 | } |
stevep | 4:81cea7a352b0 | 23 | } |
dan | 0:7dec7e9ac085 | 24 | } |