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.
Diff: main.cpp
- Revision:
- 0:c8839987d3b9
diff -r 000000000000 -r c8839987d3b9 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 20 09:18:01 2015 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "stdlib.h" + +#include "led.h" +#include "button.h" + +Led redLed("red"); +Led greenLed("green"); +Led orangeLed("orange"); +Led blueLed("blue"); + +Button button("user"); + + +int main() +{ + const float delay = 0.01f; + while(1) { + while (button.isPressed()) { + redLed.Off(); + greenLed.Off(); + orangeLed.Off(); + blueLed.Off(); + } + int led = rand() % 4; + + if(led == 0) { + redLed.On(); + } else if (led == 1) { + greenLed.On(); + } else if (led == 2) { + orangeLed.On(); + } else { + blueLed.On(); + } + + wait(delay); + } +} + +