Simon Stillwell
/
BinaryLEDDisplay
Makes the 4 onboard LEDs count in binary
main.cpp
- Committer:
- simno
- Date:
- 2010-09-06
- Revision:
- 0:7d2043a942aa
File content as of revision 0:7d2043a942aa:
#include "mbed.h" // //This is my first code for the Mbed. It's also my first c++ program. //It is based on ABetterHelloWorld by Andrew Harpin //The 4 LEDS on the Mbed repeatedly count in binary from 0 to 15 // // DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); DigitalOut myled4(LED4); Timer mytimer; int main() { myled1 = 1; myled2 = 1; myled3 = 1; myled4 = 1; mytimer.start(); int intStart = mytimer.read_ms(); int intCounter = 0; bool blnSetalloff = true; while(1) { if((mytimer.read_ms() - intStart) >= 250) { if (blnSetalloff) { myled1 = 0; myled2 = 0; myled3 = 0; myled4 = 0; blnSetalloff = false; continue; } if (intCounter % 16 > 7) { myled1 = 1; } if (intCounter % 8 > 3) { myled2 = 1; } if (intCounter % 4 > 1) { myled3 = 1; } if (intCounter % 2 == 1) { myled4 = 1; } intCounter +=1; blnSetalloff = true; intStart = mytimer.read_ms(); } } }