There are currently 0 users and 4 guests online.
C++ Library for $50 robot Version 2
Submitted by Webbot on January 2, 2009 - 12:20am.
A DC motor generally requires a PWM (speed) signal and a direction/brake pin. DC motors don't require very accurate PWM signals so this class uses PWMOut to generate the PWM signal on any output pin via software and then uses one additional output pin for controlling the direction (fwd/reverse) of the motor. Check the requirements of your DC Motor Controller or see my Motor Controller Tutorial.
So for example:-
OUT g_direction('B', 6); // Use B6 as the direction pin to the motor driver
Now we can just use the methods in Motor.hpp on g_motor. ie SetSpeed(value). This class will then sort out the setting of the direction pin and the PWM signal for you.