The STEAM Org Robotics Kit  v1
Public Member Functions | List of all members
Motor Class Reference

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.
 

Detailed Description

This allows for control of a motor through a L298N module A great explainer on how the l298N module works.

Constructor & Destructor Documentation

◆ Motor()

Motor::Motor ( u_int8_t  enb,
u_int8_t  switch1,
u_int8_t  switch2,
bool  reversed = false 
)
Parameters
enbThe PWM pin to enable the motor
switch1One switch of the H-Bridge to control motor direction
switch2One switch of the H-Bridge to control motor direction
reversedIndicates if the motor inputs should be reversed

Member Function Documentation

◆ setSpeed()

void Motor::setSpeed ( int  speed)

Sets the speed of the motor.

A negative speed indicates the motor going in the reverse direction.

Warning
Be vary of starting the motors from stop at speeds of 50 or below. The robot may not move!
Parameters
speedThe speed the motor should spin at as a value between -100 and 100

The documentation for this class was generated from the following files: