TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
BrushlessMotor< T > Class Template Reference

Simple brushless DC motor (ESC) driver using Servo library for Arduino/ESP32. More...

#include <BrushlessMotor.h>

Inheritance diagram for BrushlessMotor< T >:
Inheritance graph
[legend]
Collaboration diagram for BrushlessMotor< T >:
Collaboration graph
[legend]

Public Member Functions

 BrushlessMotor (uint8_t id=0)
 
void setPin (int pin)
 
bool begin ()
 
bool setValuePercent (T percent) override
 
getValuePercent () const override
 
void end () override
 
bool isPinsSet () const override
 
- Public Member Functions inherited from IMotor< T >
virtual bool begin ()=0
 
virtual void end ()=0
 
virtual bool isPinsSet () const =0
 
virtual bool setValuePercent (T percent)=0
 
virtual T getValuePercent () const =0
 
void setID (uint8_t id)
 
uint8_t getID () const
 

Protected Attributes

Servo servo
 
int pin = -1
 
bool is_pin_assigned = false
 
lastValuePercent = 0.0f
 
- Protected Attributes inherited from IMotor< T >
uint8_t id = 0
 

Detailed Description

template<typename T = float>
class tinyrobotics::BrushlessMotor< T >

Simple brushless DC motor (ESC) driver using Servo library for Arduino/ESP32.

This class provides an interface to control brushless DC motors (with ESCs) using the Servo or ESP32Servo library. It allows attaching to a pin, setting speed as a percentage, and detaching the servo.

Main methods:

Usage notes:

Example usage:

motor.setPin(9);
motor.begin();
motor.setSpeed(50); // 50% throttle
motor.end();
Simple brushless DC motor (ESC) driver using Servo library for Arduino/ESP32.
Definition: BrushlessMotor.h:48
void setPin(int pin)
Definition: BrushlessMotor.h:53

Member Function Documentation

◆ begin()

bool begin ( )
inlinevirtual

Implements IMotor< T >.

◆ end()

void end ( )
inlineoverridevirtual

Implements IMotor< T >.

◆ getValuePercent()

T getValuePercent ( ) const
inlineoverridevirtual

Implements IMotor< T >.

◆ isPinsSet()

bool isPinsSet ( ) const
inlineoverridevirtual

Implements IMotor< T >.

◆ setPin()

void setPin ( int  pin)
inline

Attach the servo to a pin

◆ setValuePercent()

bool setValuePercent ( percent)
inlineoverridevirtual

Implements IMotor< T >.


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