Smartcar Shield
 All Classes Namespaces Files Functions Variables Macros
Public Member Functions | List of all members
BrushedMotor Class Reference

A brushed motor is controlled via two wires where the flow of current determines the direction of rotation and the duty cycle the speed. More...

#include <BrushedMotor.hpp>

Inheritance diagram for BrushedMotor:
Inheritance graph
Collaboration diagram for BrushedMotor:
Collaboration graph

Public Member Functions

 BrushedMotor (uint8_t forwardPin, uint8_t backwardPin, uint8_t enablePin, Runtime &runtime)
 
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 brushed motor is controlled via two wires where the flow of current determines the direction of rotation and the duty cycle the speed.

For their control, we will assume the existince of a half-bridge such as the L293D chip where three signals are needed, two for determining the direction and another for determining the speed.

Examples:
automatedMovements.ino, DistanceCar.ino, FullSerialControl.ino, HeadingCar.ino, manualControl.ino, manualWithCruiseControl.ino, PidControllerMonitor.ino, rotateOnSpot.ino, shieldMotorsTest.ino, SimpleCar.ino, and SmartCar.ino.

Definition at line 22 of file BrushedMotor.hpp.

Constructor & Destructor Documentation

BrushedMotor::BrushedMotor ( uint8_t  forwardPin,
uint8_t  backwardPin,
uint8_t  enablePin,
Runtime runtime 
)

Definition at line 16 of file BrushedMotor.cpp.

Member Function Documentation

void BrushedMotor::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 28 of file BrushedMotor.cpp.

Here is the call graph for this function:


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