This is a souped up version of the basic mbed blinky, as a 2nd stepping stone up from the basic blinky and also because the documentation doesn't seem to really be that complete.
Fork of mbed_quadBlinky by
Diff: main.cpp
- Revision:
- 0:efe13d6feef8
- Child:
- 1:f4e48249b980
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 03 16:53:41 2017 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +void initialise() +{ + // Baud rate not required over USB. + led1 = 1; + led2 = 1; + led3 = 1; + led4 = 1; + wait(1.0f); + //*==========================================* + // Do initialisation here + //*==========================================* + + //*==========================================* + led1 = 0; + led2 = 0; + led3 = 0; + led4 = 0; + wait(1.0f); +} + +void updateLEDs(int val) +{ + led1 = val & 0x01; + led2 = (val & 0x02) >> 1; + led3 = (val & 0x04) >> 2; + led4 = (val & 0x08) >> 3; +} + +void advanceLEDs(int *val) +{ + *val = *val << 1; + if(*val>0x08) *val = 1; +} + +int main() +{ + initialise(); + + int i = 1; + while(1) + { + updateLEDs(i); + advanceLEDs(&i); + wait(0.5f); + } +} \ No newline at end of file