Naoki Hasegawa
/
test2
a
Diff: test2.cpp
- Revision:
- 1:7f3cd64b15e6
- Parent:
- 0:e1d7e2bd3570
- Child:
- 2:bd0c6b45d7cc
--- a/test2.cpp Mon Jun 30 04:44:08 2014 +0000 +++ b/test2.cpp Mon Jun 30 08:27:57 2014 +0000 @@ -1,22 +1,25 @@ #include "mbed.h" -DigitalOut myled(P1_14); +DigitalOut myled(P0_17); BusOut leds(P1_13, P1_14, P1_22, P0_17, P0_18, P0_19, P1_15, P0_1); void all(); void rot(); +void same(); +void roll(); int main() { while(0x01) { - myled=0x01; + myled = 0x01; wait(0.2); - myled=0x00; + myled = 0x00; wait(0.2); all(); - leds=0x00; + leds = 0x00; wait(0.2); rot(); - + same(); + roll(); } } @@ -36,6 +39,40 @@ wait(0.2); } - leds=0x00; + leds = 0x00; wait(0.2); -} \ No newline at end of file +} + +void same() +{ + int i; + for(i=0x08; i>0x00; i--) + { + leds = 0x01 << i; + wait(0.2); + all(); + } +} + +void roll() +{ + int i, j; + for(i=0x08; i>=0x00; i--) + { + leds = 0x01 << i; + wait(0.2); + for(j=0x00; j<0x08; j++){ + leds = 0x01 << j; + wait(0.2); + } + } + for(i=0x00; i<0x08; i++) + { + leds = 0x01 << i; + wait(0.2); + for(j=0x08; j>=0x00; j--){ + leds = 0x01 << j; + wait(0.2); + } + } +} \ No newline at end of file