Simple upcounter, like binary, but in graycode, using onboard LEDs

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Lerche
Date:
Sat Dec 05 19:21:03 2009 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 966104be261b main.cpp
--- /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
diff -r 000000000000 -r 966104be261b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 05 19:21:03 2009 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0