A simple Larsen scanner using the onboard LEDs.... because there aren't enough of these already.

main.cpp

Committer:
benbitwonder
Date:
2010-02-27
Revision:
0:1caccdf9730e

File content as of revision 0:1caccdf9730e:

#include "mbed.h"

BusOut ledarray(LED1, LED2, LED3, LED4);

int main(void) {
    //A flag to indicate which direction we should rotate
    bool flag = 0;
    //the states of the outputs
    char outstates = 1;

    //Place the outputs in a known state
    ledarray=1;
    
    //Infinite loop
    while(1) {
        wait(0.25);
        if (!flag) {
            outstates *= 2;
            if ((outstates>>3)&&1) flag=1;
        } else {
            outstates /=2;
            if (outstates==1) flag=0;
        }
        ledarray=outstates;
    }
}