Test script for PwmOut control LED with buttons

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
rubenlucas
Date:
Fri Sep 28 07:22:53 2018 +0000
Parent:
0:2ba57c4723ea
Commit message:
if statements not equal to 1.0 and 0.0 but just a bit below. rounding error prevention

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2ba57c4723ea -r 9654405c52f4 main.cpp
--- a/main.cpp	Wed Sep 26 12:35:57 2018 +0000
+++ b/main.cpp	Fri Sep 28 07:22:53 2018 +0000
@@ -11,7 +11,7 @@
 
 void BrighterFcn()
 {
-    if (DutyCycle == 1.0) // check if duty cycle is already at max
+    if (DutyCycle >= 0.9) // check if duty cycle is already at max
     {return;}
     else 
     {DutyCycle = DutyCycle + 0.025;} // raise duty cycle with 2.5%
@@ -19,7 +19,7 @@
 
 void DimmerFcn()
 {
-    if (DutyCycle == 0.0) // check if duty cycle is already at minimum
+    if (DutyCycle <= 0.1) // check if duty cycle is already at minimum
     {return;}
     else 
     {DutyCycle = DutyCycle - 0.025;}  // lower duty cycle with 2.5%