Homework for week 4, modified from original program as per instructions - CKM

Dependencies:   SLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
CKMonroe
Date:
Mon Sep 12 00:18:45 2016 +0000
Parent:
0:23505376c0c6
Commit message:
revised due to to instructor message

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 23505376c0c6 -r 4a283472ac8e main.cpp
--- a/main.cpp	Wed Sep 07 18:40:05 2016 +0000
+++ b/main.cpp	Mon Sep 12 00:18:45 2016 +0000
@@ -6,7 +6,12 @@
 #define NUMBUTS 2
 #define LBUT PTC12  // port addresses for buttons
 #define RBUT PTC3
-#define BLINKTIME 0.5 // in seconds //CKM: changed blinktime to 500 ms (0.5) from 0.3 (300 ms)
+
+//CKM: changed blinktime variable to 'blinkONtime' and changed length to .5 seconds (500 ms)
+//Then, added a new variable called 'blinkOFFtime', which is set to .2 seconds (200 ms).
+#define BLINKONTIME 0.5 //500 ms
+#define BLINKOFFTIME 0.2 //200 ms
+
 #define BUTTONTIME 0.2
 #define LCDCHARLEN 25 //CKM: changed character length to 25 for character array 
 #define NUMMESS 2
@@ -75,7 +80,17 @@
             }// for loop to look at buttons
             ButtonTimer.reset();
         }
-        if(LEDTimer.read() > BLINKTIME){
+        if(LEDTimer.read() > BLINKONTIME && ledState){
+            LEDTimer.reset();               
+            ledState = !ledState; // Flip the general state
+            LEDs[currentLED] = ledState;
+        }
+        //added an else if statement with regards to the state of the LED
+        //and the new variable, 'blinkOFFtime'. This will reset the LED
+        //according to the blinkOFFtime variable instead of the blinkONtime
+        //variable if the ledState is false.
+        else if (LEDTimer.read() > BLINKOFFTIME && !ledState)
+        {
             LEDTimer.reset();               
             ledState = !ledState; // Flip the general state
             LEDs[currentLED] = ledState;