Program for testing motion boards (double motor controller)
Program to test motion boards (double motor controller).
The mbed board reads from a joystick and then sends the commands to the motor board (l293d), which lets the small caterpillar go ahead, go back and turn.
Diff: dc_motor.cpp
- Revision:
- 0:5307ae36f268
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dc_motor.cpp Sat Jun 14 21:56:12 2014 +0000 @@ -0,0 +1,14 @@ +#include "dc_motor.hpp" + +DC_motor::DC_motor (PinName ppwm, PinName pdir): pwm(ppwm), dir(pdir) +{ + pwm.period(0.001); + pwm = 0; + dir = 0; +} + +void DC_motor::speed (float speed) +{ + dir = speed>0.0; + pwm = abs(speed); +}