Implementation of the MotorControllerIntf for the Adafruit_MotorShield. More...
#include <adafruit_feather_wing.h>
Public Member Functions | |
AdafruitMotorController (uint8_t motor_num, uint8_t addr=0x60) | |
Construct an AdafruitMotorController for a single motor. More... | |
void | begin (uint16_t freq=1600) |
Initializes the communication with the motor driver. More... | |
void | setSpeed (int value) override |
Set the speed of the motor pMotor_. More... | |
Private Attributes | |
Adafruit_DCMotor * | pMotor_ |
Additional Inherited Members | |
![]() | |
Adafruit_MotorShield | motor_driver_ |
Implementation of the MotorControllerIntf for the Adafruit_MotorShield.
Implements the abstract setSpeed method from the MotorControllerIntf
The class makes use of the adafruit-stepper-dc-motor-featherwing library.
Definition at line 28 of file adafruit_feather_wing.h.
diffbot::AdafruitMotorController::AdafruitMotorController | ( | uint8_t | motor_num, |
uint8_t | addr = 0x60 |
||
) |
Construct an AdafruitMotorController for a single motor.
Specify the motor to control motor_num
(use 3 or 4 for diffbot). Specify the i2c address to be used. The default address is 0x60 but it can be changed by soldering different address switches on the bottom of the PCB.
motor_num | Number of the motor to control (one of 1, 2, 3, 4). Diffbot uses motors 3 and 4. |
addr | i2c address used to communicate with the motor driver. |
Definition at line 4 of file adafruit_feather_wing.cpp.
void diffbot::AdafruitMotorController::begin | ( | uint16_t | freq = 1600 | ) |
Initializes the communication with the motor driver.
must be called in setup() to initialize the shield. An optional frequency parameter can be used to specify something other than the default maximum: 1.6KHz PWM frequency.
Definition at line 11 of file adafruit_feather_wing.cpp.
|
overridevirtual |
Set the speed of the motor pMotor_.
Concrete implementation of the setSpeed interface method to control a single motor connected to the Adafruit_MotorShield. The input parameter value
ranges from -255 to 255. Inside this method the value is mapped between 0 to 255 and the sign is used to set the direction. A positive value
results in the motor spinning forward. Negative value
rotates the motor backward and a zero value stops the motor (releases the current).
value | positive or negative value to set the direction and speed of the motor. |
Implements diffbot::MotorControllerIntf< Adafruit_MotorShield >.
Definition at line 16 of file adafruit_feather_wing.cpp.
|
private |
Definition at line 73 of file adafruit_feather_wing.h.