OhmBoyZ_Capstone / Mbed 2 deprecated Current Controller Featured

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
davidcerrone
Date:
Tue Dec 08 17:49:58 2015 +0000
Parent:
1:8897b68c1a61
Commit message:
fixed shit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8897b68c1a61 -r d53b7f599ede main.cpp
--- a/main.cpp	Thu Dec 03 03:08:31 2015 +0000
+++ b/main.cpp	Tue Dec 08 17:49:58 2015 +0000
@@ -3,8 +3,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-PwmOut pwmA(PB_3); //arduino pin 4 - D3
-PwmOut pwmB(PB_4); //arduino pin 6 - D5
+PwmOut pwmA(PB_3); //D3
+PwmOut pwmB(PB_4); //D5
 
 
 int main() {
@@ -14,26 +14,34 @@
     while(1) 
     { 
         printf("Enter a Voltage (-3.3 to 3.3 V) : \n");
-        gets(str);
+        gets(str); //get string from terminal
         
-        float voltage = atof(str);
+        float voltage = atof(str); //convert str to float
         
         printf("You entered: %s\n Output Voltage = %f \n", str, voltage);
         
-        if (voltage > 0){
+        if (voltage > 0.0){
             pwmB.write(0);
             float duty = voltage/3.3;
             printf("Duty Cycle: %f \n", duty);
             pwmA.period(0.0001);
             pwmA.write(duty);
         }
-        else if (voltage < 0){
+        else if (voltage < 0.0){
             pwmA.write(0);
             float duty = -(voltage)/3.3;
             printf("Duty Cycle: %f \n", duty);
             pwmB.period(0.0001);
             pwmB.write(duty);
         }
+        else if (voltage == 0.0){
+            pwmA.write(0);
+            pwmB.write(0);
+            pwmA.period(0.0001);
+            pwmB.period(0.0001);
+            float duty = 0;
+            printf("Duty Cycle: %f \n", duty);
+        }
         else if (voltage > 3.3 | voltage < -3.3){
             printf("Invalid Voltage input \n");
         }