Lab 3: Tommy Maly and Corwin Stites / Mbed 2 deprecated lab2programa

Dependencies:   mbed

Fork of lab2programa by Corwin Stites

Files at this revision

API Documentation at this revision

Comitter:
tmaly45
Date:
Thu Sep 27 17:01:31 2018 +0000
Parent:
3:b5310b20de62
Commit message:
Updated commenting. ;

Changed in this revision

lab2programa.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/lab2programa.cpp	Wed Sep 26 00:34:58 2018 +0000
+++ b/lab2programa.cpp	Thu Sep 27 17:01:31 2018 +0000
@@ -24,7 +24,7 @@
     a = sw1.read(); //Read in switch states
     b = sw2.read();
     
-    if (a == 1 && b == 1) //Check to see if switches 1 and 2 are on
+    if (a == 1 && b == 1) //Check to see if switche 1 AND 2 are on
     {
         lights[0]=0; //Turns on light three and turns off other lights
         lights[1]=0;
@@ -41,7 +41,7 @@
             lights[i]=1; //Turns coresponding light on
             lights[i-1]=0; //Turns last light off
             wait(.5); //Wait half a second
-            if (i == 4) //Turn last light in row off
+            if (i == 4) //Turn last light in row off in order to start sequence again. 
             {
             lights[4]=0;
             }
@@ -55,11 +55,11 @@
         lights[3]=0;
         lights[4]=0;
         int j; //Stores assignment of value in array lights
-        for (j=4; j>-1; j--) //Starts j at 4 and subtracts 1 from i while it is greater than -1
-        {
+        for (j=4; j>-1; j--) //Starts j at 4 and subtracts 1 from i while it is greater than -1. 
+        { // Because it is part of while loop, this for loop will repeat, even after j = 0. 
             lights[j]=1; //Turns the jth light in the array on
             wait(.5); //Wait half a second
-            lights[j] = 0; //Turn all lights off
+            lights[j] = 0; //Turn light off
         }
     }
     }