A blinky variation for the mBuino with a bunch of different blink modes, deep-sleeping between iterations.
Dependencies: Crypto RNG mbed WakeUp
Fork of mBuinoBlinky by
mBuino blinky experiments.
Diff: main.cpp
- Revision:
- 4:eea1a71b9a11
- Parent:
- 3:f3e484ae4439
- Child:
- 5:48b81f5fd186
diff -r f3e484ae4439 -r eea1a71b9a11 main.cpp --- a/main.cpp Fri Sep 05 01:49:07 2014 +0000 +++ b/main.cpp Fri Sep 05 02:06:56 2014 +0000 @@ -3,19 +3,15 @@ DigitalOut LED[] = {(P0_7), (P0_8), (P0_2), (P0_20), (P1_19), (P0_17), (P0_23)};// declare 7 LEDs -float delayTime = .05; int rndLED = 0; Random RNG = Random(); -int main() +void sweep(float delayTime) { - while(1) - { for(int x=0; x<7; x++) { LED[x] = 1; wait(delayTime); - // LED[x] = 0; } for(int x=6; x>=0; x--) @@ -23,7 +19,13 @@ LED[x] = 0; wait(delayTime); } - +} + +int main() +{ + while(1) + { + sweep(0.05); for(int n=0; n<128; n++) { for(int b=0; b<7; b++) { if(n & (1 << b)) { @@ -35,12 +37,25 @@ LED[b]=0; } } - + sweep(0.05); for(int x=0; x<32; x++) { rndLED = (int) RNG.getByte() % 8; LED[rndLED]=1; wait(0.1); LED[rndLED]=0; } + sweep(0.05); + for(int n=0; n<128; n++) { + int gray = (n >> 1) ^ n; + for(int b=0; b<7; b++) { + if(gray & (1 << b)) { + LED[6 - b]=1; + } + } + wait(0.05); + for(int b=0; b<7; b++) { + LED[b]=0; + } + } } }