Smartcar Shield
Public Member Functions | List of all members
DualMotor Class Reference

#include <DualMotor.hpp>

Inheritance diagram for DualMotor:
Inheritance graph
Collaboration diagram for DualMotor:
Collaboration graph

Public Member Functions

 DualMotor (Motor &motor1, Motor &motor2)
 Constructs a DualMotor object The two motors will spin in the same direction and at the same "speed". More...
 
void setSpeed (int speed) override
 Sets the motor speed and direction as the percentage of the maximum possible speed, where the sign of the argument represents the direction. More...
 
- Public Member Functions inherited from Motor
virtual ~Motor ()=default
 

Detailed Description

A set of two motors that should always spin in the same way while being controlled by different pins. This class should be used when you have two motors that are connected to the same driver on different pins but you want to control them as one.

Definition at line 14 of file DualMotor.hpp.

Constructor & Destructor Documentation

◆ DualMotor()

DualMotor::DualMotor ( Motor motor1,
Motor motor2 
)

Constructs a DualMotor object The two motors will spin in the same direction and at the same "speed".

Parameters
motor1The first motor
motor2The second motor

Definition at line 3 of file DualMotor.cpp.

Member Function Documentation

◆ setSpeed()

void DualMotor::setSpeed ( int  speed)
overridevirtual

Sets the motor speed and direction as the percentage of the maximum possible speed, where the sign of the argument represents the direction.

Parameters
speedThe speed and direction within the range of [-100, 100]. -100 means that the motor is spinning at full speed towards the direction we have defined as backward. 100 interpreted as full speed forward. 0 means that the motor is at its idle/neutral state.

Example:

motor.setSpeed(0); // Stop the motor

Implements Motor.

Definition at line 9 of file DualMotor.cpp.

Here is the call graph for this function:

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