Paul Backhouse / Mbed 2 deprecated cylon

Dependencies:   mbed

main.cpp

Committer:
paulo
Date:
2012-06-13
Revision:
0:4e5540dd971c

File content as of revision 0:4e5540dd971c:

//A simple test program to makes LEDs cycle left to right and then right to left.

#include "mbed.h"

PwmOut ledarray[4] = { LED1, LED2, LED3, LED4 };

int main() {
    bool forward = true;
    int position = 0;
    
    while (1) {
        if (position == 0) forward = true;
        else if (position == 3) forward = false;
        
        if (forward) position++;
        else position--;
        
        for (int i=0;i<4;i++) {
            if (i==position) ledarray[i] = 1.0;
            else if ((i==position-1) || (i==position+1)) ledarray[i] = 0.2;
            else ledarray[i] = 0.0;
        }
        wait(0.2);
    }
}