Task 1.3.2 Solution

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Thu Sep 24 12:24:35 2015 +0000
Commit message:
Initial version 24-09-2015

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	Thu Sep 24 12:24:35 2015 +0000
@@ -0,0 +1,51 @@
+//This is known as a “header file”
+//In short, this copies and pastes the text file
+//mbed.h into this code
+#include "mbed.h"
+
+//Create a DigitalOut “object” called myled
+//Pass constant D7 as a “parameter”
+DigitalOut redLED(D7);
+DigitalOut yellowLED(D6);
+DigitalOut greenLED(D5);
+
+//The main function - all executable C / C++
+//applications have a main function. This is
+//out entry point in the software
+int main() {
+
+    redLED = 0;
+    yellowLED = 0;
+    greenLED = 0;
+
+// ALL the code is contained in a 
+// “while loop"
+
+
+    while(1) 
+    {
+    //The code between the { curly braces }
+    //is the code that is repeated
+    
+        //STATE 1 (R) 
+        redLED = 1;
+        yellowLED = 0;
+        greenLED = 0;       
+        wait(1.0);
+        
+        //STATE 2 (RA)
+        yellowLED = 1;
+        wait(1.0);
+        
+        //STATE 3 (G)
+        redLED    = 0;
+        yellowLED = 0;
+        greenLED  = 1;
+        wait(1.0);
+        
+        //STATE 4 (A)
+        yellowLED = 1;
+        greenLED  = 0;
+        wait(1.0);        
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 24 12:24:35 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7
\ No newline at end of file