Ian Phillips
/
BinaryCounter
Diff: main.cpp
- Revision:
- 0:f8c5197531aa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 22 23:05:12 2009 +0000 @@ -0,0 +1,35 @@ +/*********************************/ +/* Binary Count on the Four LEDs */ +/* With optional Trace to TTY */ +/*********************************/ + +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx +DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4); +int p=0, q=0, r=0, s=0; + + +int main() { + led1=0,led2=0,led3=0,led4=0; + pc.printf("\n\nStart ... %d %d %d %d %s \n", p, q, r, s, "Count"); + + for (int j=0; j<256; j++) { + //wait(0.2); //Slow it down to see it + if (led1==1&&led2==1&&led3==1) { + led1=0; + led2=0; + led3=0; + led4=!led4; + } else if (led1==1&&led2==1) { + led1=0; + led2=0; + led3=!led3; + } else if (led1==1) { + led1=0; + led2=!led2; + } else led1=!led1; + //pc.printf("Now ... %d %d %d %d %d \n", p=led1, q=led2, r=led3, s=led4, j); //turn on TTY Trace (slow) + } +} +