![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Motor test
Diff: main.cpp
- Revision:
- 0:c931a374f94f
diff -r 000000000000 -r c931a374f94f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 23 08:15:14 2015 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" + +PwmOut motor_pwm(D5); +DigitalOut dir(D4); +DigitalOut led_r (LED_RED); + +//const int pwm_frequency = 10000; // PWM frequency +const float duty_cycle = 0.5; // Duty cycle (half speed) +bool direction = true; // Motor direction + + +int main() +{ +led_r.write(false); + +while(true){ +dir.write(direction); // Write motor direction +//motor_pwm.period(1/pwm_frequency); // Motor PWM period +motor_pwm.write(duty_cycle); // Set motor speed + +}}