Makes the 4 onboard LEDs count in binary

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
simno
Date:
Mon Sep 06 14:49:46 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 7d2043a942aa main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 06 14:49:46 2010 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+
+//
+//This is my first code for the Mbed. It's also my first c++ program.
+//It is based on ABetterHelloWorld by Andrew Harpin
+//The 4 LEDS on the Mbed repeatedly count in binary from 0 to 15
+//
+//
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+Timer mytimer;
+
+int main() 
+{
+    myled1 = 1;
+    myled2 = 1;
+    myled3 = 1;
+    myled4 = 1;
+    mytimer.start();
+    
+    int intStart = mytimer.read_ms();
+    int intCounter = 0;    
+    bool blnSetalloff = true;
+    while(1) 
+    {
+        if((mytimer.read_ms() - intStart) >= 250)
+        {
+            if (blnSetalloff)
+            {
+                myled1 = 0;
+                myled2 = 0;
+                myled3 = 0;
+                myled4 = 0;
+                blnSetalloff = false;
+                continue;
+            }
+
+            if (intCounter % 16 > 7)
+            {
+                myled1 = 1;
+            }
+            if (intCounter % 8 > 3)
+            {
+                myled2 = 1;
+            }
+            if (intCounter % 4 > 1)
+            {
+                myled3 = 1;
+            }
+            if (intCounter % 2 == 1)
+            {
+                myled4 = 1;
+            }
+            intCounter +=1;
+            blnSetalloff = true;
+            intStart = mytimer.read_ms();
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 7d2043a942aa mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 06 14:49:46 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e