code

Dependencies:   FastPWM HIDScope mbed

Fork of Motor_Rotator by Eki Liptiay

Revision:
1:aab087815027
Parent:
0:5746f50d8ee4
Child:
2:328fa2eb6437
--- a/main.cpp	Thu Sep 27 08:37:30 2018 +0000
+++ b/main.cpp	Thu Sep 27 13:09:29 2018 +0000
@@ -4,15 +4,15 @@
 // Motor 1 has PWM-pin D5 and direction-pin D4
 
 AnalogIn pot1(A0);
-DigitalOut directionpin(D4);
-PwmOut pwmpin(D5);
+DigitalOut directionpin(D7);
+PwmOut pwmpin(D6);
 HIDScope scope(1); // We’re going to send 1 channel of data
 Ticker AInTicker;
 
 void ReadAnalogInAndFilter()
 {
-        float u = 2.0f*pot1-1.0f;
-        scope.set(0, u);  // Brightness is saved in the first scope.
+        float a = 2.0f*pot1-1.0f;
+        scope.set(0, a);  // Brightness is saved in the first scope.
         scope.send(); // send what's in scope memory to PC
 }
 
@@ -22,7 +22,7 @@
     while (true) {
         float u = 2.0f*pot1-1.0f; //determine useful value, -0.3f is just an example
         directionpin = u > 0.0f; //either true or false
-        pwmpin.write = fabs(u); //pwm duty cycle can only be positive, floating point absolute value
+        pwmpin = fabs(u); //pwm duty cycle can only be positive, floating point absolute value
         wait(0.001f);
     }
 }
\ No newline at end of file