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:
- 7:c9e707fc8aa3
- Parent:
- 6:fe79549495e0
- Child:
- 8:41a5757f3bb9
diff -r fe79549495e0 -r c9e707fc8aa3 main.cpp --- a/main.cpp Fri Sep 05 02:46:07 2014 +0000 +++ b/main.cpp Sat Sep 06 01:07:01 2014 +0000 @@ -38,6 +38,24 @@ } } +void pileMode(float delayTime) +{ + for(int x=0; x<7; x++) + { + for(int y=0; y<(6-x); y++) { + LED[y]=1; + wait(delayTime); + LED[y]=0; + } + LED[6-x]=1; + } + + for(int x=0; x<7; x++) + { + LED[x] = 0; + } +} + void randomMode(float delayTime) { for(int x=0; x<128; x++) { @@ -64,17 +82,21 @@ } void grayMode(float delayTime) { - for(int n=0; n<128; n++) { + for(int b=0; b<7; b++) { LED[b]=0; } + + int prev=0; + for(int n=1; n<128; n++) { + int prevGray = (prev >> 1) ^ prev; int gray = (n >> 1) ^ n; + int diffBit = prevGray ^ gray; for(int b=0; b<7; b++) { - if(gray & (1 << b)) { - LED[6 - b]=1; + if(diffBit & (1 << b)) { + LED[6 - b] = (diffBit & prevGray) ? 0 : 1; + break; } } + prev = n; wait(delayTime); - for(int b=0; b<7; b++) { - LED[b]=0; - } } } @@ -85,11 +107,13 @@ sweep(0.05); binaryMode(0.05); sweep(0.05); - randomMode(0.025); + randomMode(0.05); sweep(0.05); grayMode(0.05); sweep(0.05); - bounceMode(0.1); - bounceMode(0.1); + bounceMode(0.05); + sweep(0.05); + pileMode(0.05); + // bounceMode(0.1); } }