John Warren
/
BinaryCounter
very Basic Binary counter.... more fun than the old blink example
Diff: main.cpp
- Revision:
- 0:7740e34b2aa5
diff -r 000000000000 -r 7740e34b2aa5 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 22 06:22:34 2011 +0000 @@ -0,0 +1,105 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +DigitalOut myled2(LED2); +DigitalOut myled3(LED3); +DigitalOut myled4(LED4); + +int t=0; + +int main() { +for(int i=0; i<16; i++) { + wait(1); + printf("The second is %i \n\r", t); + t+=1; + switch(i) + { + case 1: + myled = 1; + break; + case 2: + myled = 0; + myled2 = 1; + break; + case 3: + myled = 1; + myled2 = 1; + break; + case 4: + myled = 0; + myled2 = 0; + myled3 = 1; + break; + case 5: + myled = 1; + myled2 = 0; + myled3 = 1; + break; + case 6: + myled = 0; + myled2 = 1; + myled3 = 1; + break; + case 7: + myled = 1; + myled2 = 1; + myled3 = 1; + break; + case 8: + myled = 0; + myled2 = 0; + myled3 = 0; + myled4 = 1; + break; + case 9: + myled = 1; + myled2 = 0; + myled3 = 0; + myled4 = 1; + break; + case 10: + myled = 0; + myled2 = 1; + myled3 = 0; + myled4 = 1; + break; + case 11: + myled = 1; + myled2 = 1; + myled3 = 0; + myled4 = 1; + break; + case 12: + myled = 0; + myled2 = 0; + myled3 = 1; + myled4 = 1; + break; + case 13: + myled = 1; + myled2 = 0; + myled3 = 1; + myled4 = 1; + break; + case 14: + myled = 0; + myled2 = 1; + myled3 = 1; + myled4 = 1; + break; + case 15: + myled = 1; + myled2 = 1; + myled3 = 1; + myled4 = 1; + break; + default : + myled = 0; + myled2 = 0; + myled3 = 0; + myled4 = 0; + break; + + }; +} +} \ No newline at end of file