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:
- 2:fd6008aa85cd
- Parent:
- 1:47c61bf9c81e
- Child:
- 3:f3e484ae4439
diff -r 47c61bf9c81e -r fd6008aa85cd main.cpp --- a/main.cpp Thu Sep 04 11:20:33 2014 +0000 +++ b/main.cpp Fri Sep 05 01:34:02 2014 +0000 @@ -1,32 +1,34 @@ #include "mbed.h" +#include "RNG/Random.h" 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() { while(1) { - if(delayTime > 0.5) - { - delayTime = 0.05; - } for(int x=0; x<7; x++) { LED[x] = 1; wait(delayTime); - LED[x] = 0; - //wait(delayTime); + // LED[x] = 0; } - for(int x=5; x>0; x--) + + for(int x=6; x>=0; x--) { - LED[x] = 1; + LED[x] = 0; wait(delayTime); - LED[x] = 0; - //wait(delayTime); } - delayTime = delayTime * 1.5; + for(int x=0; x<20; x++) { + rndLED = (int) RNG.getByte() % 8; + LED[rndLED]=1; + wait(0.2); + LED[rndLED]=0; + } } }