The STEAM Org Robotics Kit
v1
|
This allows for control of a motor through a L298N module A great explainer on how the l298N module works. More...
#include <Motor.h>
Public Member Functions | |
Motor (u_int8_t enb, u_int8_t switch1, u_int8_t switch2, bool reversed=false) | |
void | setSpeed (int speed) |
Sets the speed of the motor. More... | |
void | stop () |
Stops the motor by turning off both switches in the H-Bridge. | |
This allows for control of a motor through a L298N module A great explainer on how the l298N module works.
Motor::Motor | ( | u_int8_t | enb, |
u_int8_t | switch1, | ||
u_int8_t | switch2, | ||
bool | reversed = false |
||
) |
enb | The PWM pin to enable the motor |
switch1 | One switch of the H-Bridge to control motor direction |
switch2 | One switch of the H-Bridge to control motor direction |
reversed | Indicates if the motor inputs should be reversed |
void Motor::setSpeed | ( | int | speed | ) |
Sets the speed of the motor.
A negative speed indicates the motor going in the reverse direction.
speed | The speed the motor should spin at as a value between -100 and 100 |