Git Product home page Git Product logo

echicken / a4988 Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 5.0 21 KB

Use an A4988 stepper motor controller on a Raspberry Pi with node.js

License: MIT License

JavaScript 100.00%
a4988 a4988-stepper-motor-driver raspberry-pi stepper stepper-motor stepper-motor-driver stepper-motor-control stepper-controller stepper-driver stepper-library stepper-control steppermotor motor motor-controller motor-driver motors robotics

a4988's Introduction

A4988

Use an A4988 stepper motor controller on a Raspberry Pi with node.js

const A4988 = require('A4988');
const a4988 = new A4988({ step: 6, dir: 5 });
a4988.turn(5000).then(steps => console.log(`Turned ${steps} steps`));

Constructor

new A4988({ step: 26, dir: 19, ms1: 13, ms2: 6, ms3: 5, enable: 22 }); // ms1, ms2, ms3, and enable are optional

All parameters are BCM GPIO pin numbers wired to the corresponding A4988 pins.

The ms1, ms2, and ms3 parameters are optional, but required if you want microstepping (step_size below).

Properties

  • direction - boolean - Clockwise or counterclockwise, depending on wiring (I think)
  • delay - number - Milliseconds between steps (pulses) (default is 1, which works for me)
  • step_size - string - 'full', 'half', 'quarter', 'eighth', or 'sixteenth'
    • ms1, ms2, and ms3 must be wired up and provided to constructor
  • enabled - boolean - Enable or disable the controller. Set 'true' to enable (default), 'false' to disable. This is at odds with how the pin actually works (active-low) but is clearer.

Methods

  • turn(steps [, callback]) - Will fire callback when turn is complete (or aborted). If callback not given, returns a Promise
    • Return value (or callback param) is the number of steps actually taken, which may vary from steps if stop() was called and the turn was aborted prematurely.
  • stop() - Abort a turn in progress

a4988's People

Contributors

echicken avatar

Stargazers

 avatar

Watchers

 avatar  avatar

a4988's Issues

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.