Thom Kuenen
/
Turning_motor
First attempt at Milestone_1. Commit for progress information
main.cpp
- Committer:
- ThomBMT
- Date:
- 2018-09-28
- Revision:
- 0:7fd3327ceec4
File content as of revision 0:7fd3327ceec4:
#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); } }