Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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);
    }
}