Skip to content

gallingern/arduino-motor-shield-r3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 

Repository files navigation

Arduino library for the Arduino Motor Driver Shield R3

Version: 1.0.0
Release Date: 2015-04-22
http://www.arduino.cc/en/Main/ArduinoMotorShieldR3

Summary

This is a library for the Arduino that interfaces with the Arduino Motor Driver Shield R3. It makes it simple to drive two brushed, DC motors.

Getting Started

Software

Download the archive from GitHub, decompress it, and move the “ArduinoMotorShieldR3” folder into the “libraries” subdirectory inside your Arduino sketchbook directory. You can view your sketchbook location by selecting File→Preferences in the Arduino environment; if there is not already a “libraries” folder in that location, you should create it yourself. After installing the library, restart the Arduino environment so it can find the ArduinoMotorShieldR3 library and its examples.

Hardware

The Arduino Motor Driver Shield R3 can be purchased on Arduino’s website. See the motor shield user’s guide for more details.

Example Program

Demo

Open this example code sketch by selecting File→Examples→ArduinoMotorShieldR3→Demo.

The demo runs both motors forward, then backward at 100%, then 50% speed. Both motor’s current readings are sent over serial and can be seen with the serial monitor.

Library Reference

ArduinoMotorShieldR3()
Default constructor, selects the default pins as connected by the motor shield.
ArduinoMotorShieldR3unsigned char DIR_A, unsigned char BRK_A, unsigned char PWM_A, unsigned char CS_A, unsigned char DIR_B, unsigned char BRK_B, unsigned char PWM_B, unsigned char CS_B)
Alternate constructor for shield connections remapped by user.
void init()
Initialize pinModes.
void setM1Speed(int speed)
Set speed and direction for motor 1. Speed should be between -400 and 400.
void setM2Speed(int speed)
Set speed and direction for motor 2. Speed should be between -400 and 400.
void setSpeeds(int m1Speed, int m2Speed)
Set speed and direction for motor 1 and 2.
void setM1Brake()
Set brake for motor 1.
void setM2Brake()
Set brake for motor 2.
void setBrakes()
Set brake for motor 1 and 2.
unsigned int getM1CurrentMilliamps()
Returns current reading from motor 1 in milliamps.
unsigned int getM2CurrentMilliamps()
Returns current reading from motor 2 in milliamps.

Version History

About

Arduino library for the Arduino Motor Shield R3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 72.0%
  • Other 28.0%