4180Lab1Part1&2

Dependencies:   mbed

Revision:
2:51a94a489f09
Parent:
1:dcefd568845d
diff -r dcefd568845d -r 51a94a489f09 main.cpp
--- a/main.cpp	Tue Jan 24 23:51:32 2017 +0000
+++ b/main.cpp	Mon Feb 27 22:30:08 2017 +0000
@@ -1,6 +1,5 @@
 #include "mbed.h"
 
-DigitalOut myled(LED1);
 DigitalOut myled2(p25);
 PwmOut myled3(p21);
 DigitalIn pb(p24);
@@ -14,30 +13,31 @@
     pwmdown.mode(PullUp);
     
     // Part 2
-    myled3.period(1.0f);
+    myled3.period(0.01f);
     volatile float duty = 0.50f;
     myled3.write(duty);
+    
     while(1) {
         // Part 1
         while(pb == 0) {
-            myled = 1;
             myled2 = 0;
         }
-        myled = 0;
         myled2 = 1;
         
         // Part 2
         if(pwmup == 0 && duty < 1.00f) {
-            duty = duty + 0.001f;
-            //duty += 0.10f;
+            //duty = duty + 0.001f;
+            duty += 0.05f;
             //duty = 1.0f;
             myled3.write(duty);
+            while(pwmup == 0) {}
         }
         if(pwmdown == 0 && duty > 0.00f) {
-            duty = duty - 0.001f;
-            //duty -= 0.10f;
+            //duty = duty - 0.001f;
+            duty -= 0.05f;
             //duty = 0.0f;
             myled3.write(duty);
+            while(pwmdown == 0) {}
         }
     }
 }