Using the A4988 breakout with Arduino involves wiring up the breakout with a stepper motor to your Arduino-compatible microcontroller and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the breakout VDD.
Here is an Adafruit Metro wired up to the breakout with a stepper motor. You'll need to connect the stepper motor power supply to the DC jack on the Metro.
Check your stepper motor wiring - your motor may have different wire colors or wire order.
- Stepper motor power supply to Metro DC Jack
- Breakout VDD to Metro 5V (red wire)
- Breakout GND to Metro GND (black wire)
- Breakout DIR to Metro pin 5 (blue wire)
- Breakout STEP to Metro pin 6 (orange wire)
- Breakout terminal block + to Metro VIN (red wire)
- Breakout 1A to stepper motor coil 1 positive (green wire)
- Breakout 1B to stepper motor coil 1 negative (yellow wire)
- Breakout 2A to stepper motor coil 2 positive (red wire)
- Breakout 2B to stepper motor coil 2 negative (black wire)
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT const int DIR = 5; const int STEP = 6; const int microMode = 16; // microstep mode, default is 1/16 so 16; ex: 1/4 would be 4 // full rotation * microstep divider const int steps = 200 * microMode; void setup() { // setup step and dir pins as outputs pinMode(STEP, OUTPUT); pinMode(DIR, OUTPUT); } void loop() { // change direction every loop digitalWrite(DIR, !digitalRead(DIR)); // toggle STEP to move for(int x = 0; x < steps; x++) { digitalWrite(STEP, HIGH); delay(2); digitalWrite(STEP, LOW); delay(2); } delay(1000); // 1 second delay }
Upload the sketch to your board. You'll see your attached stepper motor turn slowly clockwise and then reverse and turn slowly counterclockwise.
Text editor powered by tinymce.