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.

Dependencies:   mbed

Fork of mbed_quadBlinky by Jason Tay

main.cpp

Committer:
shutay
Date:
2017-10-03
Revision:
0:efe13d6feef8
Child:
1:f4e48249b980

File content as of revision 0:efe13d6feef8:

#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);
    }
}