A simple binary counter program that uses the onboard mbed leds to represent bits

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
nbitwonder
Date:
Fri Mar 19 17:08:07 2010 +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 824a95146598 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 19 17:08:07 2010 +0000
@@ -0,0 +1,29 @@
+/****************************************************************************************
+* Date Created: 2/26/2010
+* Title: NBitWonder Binary Counter Code Example
+* Description: A binary adder implemented using the mbed embedded development platform.
+*       This program utilizes the mbed's 4 onboard leds to represent the value of a 4-bit
+*       binary variable. The variable begins at 0 and is incremented once every second.
+* Author: George Hadley
+* Website: http://nbitwonder.com
+****************************************************************************************/
+#include "mbed.h"
+
+//LED Output initializations
+BusOut Bits(LED1,LED2,LED3,LED4); //LED outputs for counter
+
+char bin_val = 0x00;
+int main() {
+    while(1) {
+        //increment bin_val, resetting if 4-bit overflow condition occurs
+        bin_val++;
+        if(bin_val > 0x0F) 
+        {
+            bin_val = 0;
+        }
+        //Assign bin_val to led output
+        Bits = bin_val;
+        //wait 1 second
+        wait(1);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 824a95146598 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 19 17:08:07 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0