Thom Kuenen
/
Turning_motor
First attempt at Milestone_1. Commit for progress information
Diff: main.cpp
- Revision:
- 0:7fd3327ceec4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 28 13:43:53 2018 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +DigitalOut DirectionPin1(D4); +PwmOut PwmPin1(D5); +DigitalOut DirectionPin2(D7); +PwmOut PwmPin2(D6); + + + +int main() +{ +PwmPin1.period_us(120); //60 microseconds pwm period, 16.7 kHz + for(;;) + { + float u = -0.4f; //determine useful value, this is not final + DirectionPin1 = u > 0.0f; //either true or false + // True = CW, for False = CW + PwmPin1 = fabs(u); //PWM duty cycle can only be positive, floating point absolute value + + float v = 0.5f; + DirectionPin2 = v > 0.0f; + // FIXED! True = CCW, Flase = CW + PwmPin2 = fabs(v); + } +} \ No newline at end of file