Björn Nijhuis
/
motor_test
Motor test
Revision 0:c931a374f94f, committed 2015-09-23
- Comitter:
- bjornnijhuis
- Date:
- Wed Sep 23 08:15:14 2015 +0000
- Commit message:
- Initial commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /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 + +}}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Sep 23 08:15:14 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa \ No newline at end of file