Adafruit Motor Shield V2 Arduino Library
|
#include <Adafruit_MotorShield.h>
Public Member Functions | |
Adafruit_MotorShield (uint8_t addr=0x60) | |
Create the Motor Shield object at an I2C address, default is 0x60. More... | |
bool | begin (uint16_t freq=1600, TwoWire *theWire=&Wire) |
Initialize the I2C hardware and PWM driver, then turn off all pins. More... | |
Adafruit_DCMotor * | getMotor (uint8_t n) |
Mini factory that will return a pointer to an already-allocated Adafruit_DCMotor object. Initializes the DC motor and turns off all pins. More... | |
Adafruit_StepperMotor * | getStepper (uint16_t steps, uint8_t n) |
Mini factory that will return a pointer to an already-allocated Adafruit_StepperMotor object with a given 'steps per rotation. Then initializes the stepper motor and turns off all pins. More... | |
void | setPWM (uint8_t pin, uint16_t val) |
Helper that sets the PWM output on a pin and manages 'all on or off'. More... | |
void | setPin (uint8_t pin, boolean val) |
Helper that sets the PWM output on a pin as if it were a GPIO. More... | |
Friends | |
class | Adafruit_DCMotor |
Let DCMotors control the Shield. | |
Object that controls and keeps state for the whole motor shield. Use it to create DC and Stepper motor objects!
Adafruit_MotorShield::Adafruit_MotorShield | ( | uint8_t | addr = 0x60 | ) |
Create the Motor Shield object at an I2C address, default is 0x60.
addr | Optional I2C address if you've changed it |
bool Adafruit_MotorShield::begin | ( | uint16_t | freq = 1600 , |
TwoWire * | theWire = &Wire |
||
) |
Initialize the I2C hardware and PWM driver, then turn off all pins.
freq | The PWM frequency for the driver, used for speed control and microstepping. By default we use 1600 Hz which is a little audible but efficient. |
theWire | A pointer to an optional I2C interface. If not provided, we use Wire or Wire1 (on Due) |
Adafruit_DCMotor * Adafruit_MotorShield::getMotor | ( | uint8_t | num | ) |
Mini factory that will return a pointer to an already-allocated Adafruit_DCMotor object. Initializes the DC motor and turns off all pins.
num | The DC motor port we want to use: 1 thru 4 are valid |
Adafruit_StepperMotor * Adafruit_MotorShield::getStepper | ( | uint16_t | steps, |
uint8_t | num | ||
) |
Mini factory that will return a pointer to an already-allocated Adafruit_StepperMotor object with a given 'steps per rotation. Then initializes the stepper motor and turns off all pins.
steps | How many steps per revolution (used for RPM calculation) |
num | The stepper motor port we want to use: only 1 or 2 are valid |
void Adafruit_MotorShield::setPWM | ( | uint8_t | pin, |
uint16_t | value | ||
) |
Helper that sets the PWM output on a pin and manages 'all on or off'.
pin | The PWM output on the driver that we want to control (0-15) |
value | The 12-bit PWM value we want to set (0-4095) - 4096 is a special 'all on' value |
void Adafruit_MotorShield::setPin | ( | uint8_t | pin, |
boolean | value | ||
) |
Helper that sets the PWM output on a pin as if it were a GPIO.
pin | The PWM output on the driver that we want to control (0-15) |
value | HIGH or LOW depending on the value you want! |