GithubHelp home page GithubHelp logo

morristech / a4990-motor-shield Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pololu/a4990-motor-shield

0.0 1.0 0.0 18 KB

Arduino library for the Pololu A4990 Dual Motor Driver Shield for Arduino http://www.pololu.com/product/2512

License: MIT License

C++ 100.00%

a4990-motor-shield's Introduction

Arduino library for the Pololu A4990 Dual Motor Driver Shield

Version: 2.0.0
Release date: 2016-08-18
www.pololu.com

Summary

This is a library for an Arduino-compatible controller that interfaces with the Pololu A4990 Dual Motor Driver Shield for Arduino. It makes it simple to drive two brushed, DC motors.

Getting started

Hardware

The Pololu A4990 Dual Motor Driver Shield for Arduino can be purchased on Pololu's website. Before continuing, careful reading of the product page is recommended.

Compatible Arduino boards

This shield should work with all Arduino boards and clones that behave like a standard Arduino board. We have specifically tested this shield (using this Arduino library) with:

  • Arduino Uno R3
  • Arduino Leonardo
  • Arduino Mega 2560
  • Arduino Due
  • Arduino Duemilanove (ATmega328P)

This library configures Timer 1 on the Uno R3, Leonardo, and Duemilanove to generate a 20 kHz PWM frequency for the motors. The library uses analogWrite on any board that does not use an ATmega168, ATmega328P or ATmega32U4. On the Mega 2560 and Due, analogWrite generates 489 Hz and 1 kHz PWM frequencies, respectively, with the default timer configuration.

Software

If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install this library:

  1. In the Arduino IDE, open the "Sketch" menu, select "Include Library", then "Manage Libraries...".
  2. Search for "A4990MotorShield".
  3. Click the A4990MotorShield entry in the list.
  4. Click "Install".

If this does not work, you can manually install the library:

  1. Download the latest release archive from GitHub and decompress it.
  2. Rename the folder "lps-arduino-xxxx" to "A4990MotorShield".
  3. Drag the "A4990MotorShield" folder into the "libraries" directory inside your Arduino sketchbook directory. You can view your sketchbook location by opening the "File" menu and selecting "Preferences" in the Arduino IDE. If there is not already a "libraries" folder in that location, you should make the folder yourself.
  4. After installing the library, restart the Arduino IDE.

Example program

An example sketch is available that shows how to use the library. You can access it from the Arduino IDE by opening the "File" menu, selecting "Examples", and then selecting "A4990MotorShield". If you cannot find these examples, the library was probably installed incorrectly and you should retry the installation instructions above.

Demo

The demo ramps motor 1 from stopped to full speed forward, ramps down to full speed reverse, and back to stopped. Then, it does the same with the other motor.

Documentation

  • void setM1Speed(int speed)
    Set speed and direction for motor 1. Speed should be between -400 and 400. The motors brake at 0 speed. Positive speeds correspond to motor current flowing from M1A to M1B. Negative speeds correspond to motor current flowing from M1B to M1A.
  • void setM2Speed(int speed)
    Set speed and direction for motor 2. Speed should be between -400 and 400. The motors brake at 0 speed. Positive speeds correspond to motor current flowing from M2A to M2B. Negative speeds correspond to motor current flowing from M2B to M2A.
  • void setSpeeds(int m1Speed, int m2Speed)
    Set speed and direction for motor 1 and 2.
  • void flipM1(bool flip)
    Flip the direction meaning of the speed passed to the setSpeeds function for motor 1. The default direction corresponds to flipM1(false) having been called.
  • void flipM2(bool flip)
    Flip the direction meaning of the speed passed to the setSpeeds function for motor 2. The default direction corresponds to flipM2(false) having been called.
  • bool getFault()
    Returns true if pin 6 is being driven low by one of the error flag outputs.

Version history

  • 2.0.0 (2016-08-18): Updated library to work with the Arduino Library Manager.
  • 1.0.0 (2014-08-15): Original release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.