Lab 1 / Mbed 2 deprecated V2

Dependencies:   mbed

Fork of Version1-SD by Lab 1

Files at this revision

API Documentation at this revision

Comitter:
m211482
Date:
Thu Sep 20 15:35:55 2018 +0000
Parent:
0:c8d5f36a69d4
Commit message:
b

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Sep 20 15:22:12 2018 +0000
+++ b/main.cpp	Thu Sep 20 15:35:55 2018 +0000
@@ -8,34 +8,34 @@
 int main()
 {
     while(1) {//while to keep loop going//
-        SW1= sw1.read();//read in switches//
+        SW1=sw1.read();//read in switches//
         SW2=sw2.read();
         if ((SW1==1) && (SW2==1)) {//if switch one and two are on//
-        p=2;
-        for(i=0;i<5;i++){//to turn on only led3 on and the rest off//
-            if(i==p){
-                led[i]=1;
+            p=2;
+            for(i=0; i<5; i++) { //to turn on only led3 on and the rest off//
+                if(i==p) {
+                    led[i]=1;
                 }//end if//
-                else{
-            led[i]=0;
-            }//end else
-        } //end for// 
+                else {
+                    led[i]=0;
+                }//end else
+            } //end for//
         }//end if//
         else if (SW1==1) { //if only switch one is on//
-            if(p<4){//to prevent any led greater than 5 to be used//
+            if(p<4) { //to prevent any led greater than 5 to be used//
                 led[p]=0;
                 p++;
                 led[p]=1;
+                }
                 wait(0.5);
-            }//end if//
         }//end else if//
         else if (SW2==1) {//if only switch two is on//
-        if(p>0){//to ensure no negative numbers are present//
-            led[p]=0;
-            p--;
-            led[p]=1;
+            if(p>0) { //to ensure no negative numbers are present//
+                led[p]=0;
+                p--;
+                led[p]=1;
+                }
                 wait(0.5);
-            }//end if//
         }//end else if//
     }//end while
 }//end main