by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
robt
Date:
Fri Aug 31 15:21:31 2012 +0000
Commit message:
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 31 15:21:31 2012 +0000
@@ -0,0 +1,27 @@
+/*Program Example 3.1: Demonstrates use of while loops. No external connection required
+                                                                               */
+#include "mbed.h"
+DigitalOut myled(LED1);
+DigitalOut yourled(LED4);
+
+int main()
+{
+    char i=0;         //declare variable i, and set to 0
+    while(1) {        //start endless loop
+        while(i<10) {     //start first conditional while loop
+            myled = 1;
+            wait(0.2);
+            myled = 0;
+            wait(0.2);
+            i = i+1;         //increment i
+        }                  //end of first conditional while loop
+        while(i>0) {       //start second conditional loop
+            yourled = 1;
+            wait(0.2);
+            yourled = 0;
+            wait(0.2);
+            i = i-1;
+        }
+    }                  //end infinite loop block
+}                    //end of main
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Aug 31 15:21:31 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc
\ No newline at end of file