Mbed example of while loop usage

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
efoster79
Date:
Sat Nov 08 14:30:32 2014 +0000
Commit message:
Program Example 3.1 - Played with while loop on mbed plus function definition.

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 26a385b70b8b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 08 14:30:32 2014 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+DigitalOut yourled(LED4);
+
+void setled(DigitalOut,int);
+
+int main(){
+    
+    char i = 0;
+    
+    while(1){
+        while(i<10){
+            setled(myled,1);
+            wait(0.2);
+            setled(myled,0);
+            wait(0.2);    
+            i++;
+        }        
+        while(i>0){
+            setled(yourled,1);
+            wait(0.2);
+            setled(yourled,0);
+            wait(0.2);
+            i--;    
+        }
+    }    
+}
+void setled(DigitalOut obj, int status){
+        obj.write(status); // obj = status
+}
\ No newline at end of file
diff -r 000000000000 -r 26a385b70b8b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 08 14:30:32 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e