Christian Lerche
/
GrayCount
Simple upcounter, like binary, but in graycode, using onboard LEDs
Diff: main.cpp
- Revision:
- 0:966104be261b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 05 19:21:03 2009 +0000 @@ -0,0 +1,25 @@ +/* + +Author: Christian Lerche +Date: 05-12-2009 +MCU: LPC1768 +Notes: Simple graycode upcounter, using onboard LEDs. + +*/ + +#include "mbed.h" + +BusOut LEDs(LED4, LED3, LED2, LED1); // Make 4 bit bus with LEDs +unsigned char i; // Char to read for LEDs + +int main() { // Main structure + i=0; // initialize i to 0 + while(1) { // While-loop (Do forever) + LEDs=i^(i>>1); // This converts the binary to graycode + wait(0.5); // Wait for .5 seconds + i=i+1; // Every loop, add one to i + if(i==16) { // If i is 16, make i 0 + i=0; // This makes it 0 + } // End of if + } // End of while-loop (Do not anymore) +} // End of main structure \ No newline at end of file