4180Lab1Part1&2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
CRaslawski
Date:
Mon Feb 27 22:30:08 2017 +0000
Parent:
1:dcefd568845d
Commit message:
initial upload

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
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) {}
         }
     }
 }