![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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:
- 5:48b81f5fd186
- Parent:
- 4:eea1a71b9a11
- Child:
- 6:fe79549495e0
--- a/main.cpp Fri Sep 05 02:06:56 2014 +0000 +++ b/main.cpp Fri Sep 05 02:17:25 2014 +0000 @@ -21,30 +21,31 @@ } } -int main() +void randomMode(float delayTime) { - while(1) - { - sweep(0.05); + for(int x=0; x<128; x++) { + rndLED = (int) RNG.getByte() % 8; + LED[rndLED]=1; + wait(delayTime); + LED[rndLED]=0; + } +} + +void binaryMode(float delayTime) { for(int n=0; n<128; n++) { for(int b=0; b<7; b++) { if(n & (1 << b)) { LED[6 - b]=1; } } - wait(0.05); + wait(delayTime); for(int b=0; b<7; b++) { 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); +} + +void grayMode(float delayTime) { for(int n=0; n<128; n++) { int gray = (n >> 1) ^ n; for(int b=0; b<7; b++) { @@ -52,10 +53,22 @@ LED[6 - b]=1; } } - wait(0.05); + wait(delayTime); for(int b=0; b<7; b++) { LED[b]=0; } } +} + +int main() +{ + while(1) + { + sweep(0.05); + binaryMode(0.05); + sweep(0.05); + randomMode(0.025); + sweep(0.05); + grayMode(0.05); } }