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

A motor that is controlled via the length of pulses that are sent to it through a single signal line. More...

#include <ServoMotor.hpp>

Inheritance diagram for ServoMotor:
Inheritance graph
Collaboration diagram for ServoMotor:
Collaboration graph

Public Member Functions

 ServoMotor (uint8_t controlPin, int minPulseLength, int idlePulseLength, int maxPulseLength, 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 motor that is controlled via the length of pulses that are sent to it through a single signal line.

It can be either a traditional servo motor that controls a shaft (e.g. for steering) or an Electronic Speed Controller (ESC) that interpets speed in the same manner and controls a (typically brushless) motor.

Examples:
SerialControlServoESC.ino.

Definition at line 36 of file ServoMotor.hpp.

Constructor & Destructor Documentation

ServoMotor::ServoMotor ( uint8_t  controlPin,
int  minPulseLength,
int  idlePulseLength,
int  maxPulseLength,
Runtime runtime 
)

Definition at line 7 of file ServoMotor.cpp.

Member Function Documentation

void ServoMotor::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 21 of file ServoMotor.cpp.

Here is the call graph for this function:


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