Brandon Roots
  • INTERACTIVE
  • FILM
  • ABOUT
  • CONTACT
November 16, 2020

Lab: Controlling a Stepper Motor With an H-Bridge

broots ITP, Physical Computing

In this lab I learned to control the functions of a stepper motor through a motor driver board that handles power functions for the motor and communicates with an Arduino.

The motor controller on hand was a A4988 Stepper Motor Driver Carrier from Pololu. The A4988 board pinout and basic wiring diagram here:

My setup with the Arduino Mega and a Nemo 12-volt stepper motor looked like this, running pins 2 (for direction) and 3 (for steps) from the Arduino:

Using a tutorial from MarkerGuides.com as a starting point I was able to run their Arduino sketch which is copied at the bottom of this page.

This is missing something…

Ah, much better.

It is interesting to consider that while using the motor driver board no libraries were necessary to control the Nema stepper motor.

// Define stepper motor connections and steps per revolution:
#define dirPin 2
#define stepPin 3
#define stepsPerRevolution 200

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  // Set the spinning direction clockwise:
  digitalWrite(dirPin, HIGH);

  // Spin the stepper motor 1 revolution slowly:
  for (int i = 0; i < stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(8000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(8000);
  }

}
Lab: DC Motor Control Using an H-Bridge Sound Project: The Dark Attic

Related Posts

Fractal Plant – Foiled by  Registers

Homemade Hardware, ITP, Solar Plant

Fractal Plant – Foiled by Registers

Since receiving the PCBs and successfully soldering the board together I have been trying to rewrite code for the I2C port expander. This has been immensely difficult! The Inkplate Arduino Library makes considerable use of an “Mcp” class, which is written to work with the MCP23017 GPIO expander IC. These chips are quite difficult to […]

“Handling” Playtest Week

Handling, ITP

“Handling” Playtest Week

Last week we attended “Playtest Thursday” on the second floor of 370 Jay St with our games. I came away from the experience with some very specific feedback. Seeing a number of people play the game showed me things I didn’t anticipate. Some folks approached the cabinet and immediately treated it as a touch screen. […]

Fractal Plant – Beta Build

Homemade Hardware, ITP, Solar Plant

Fractal Plant – Beta Build

The boards arrived! Amazingly within an hour of one another. Based on the experience I think that JLCPCB is a better value. With shipping OSHPark was $55.50 for 3 boards. JLCPCB was $26.36 for 10 boards. Aside from a higher cost OSHPark also left sharp bits of tabs around the edges of the boards which […]

Recent Posts

  • Fractal Plant – Foiled by  RegistersFractal Plant – Foiled by Registers
    May 9, 2022
  • “Handling” Playtest Week“Handling” Playtest Week
    May 5, 2022
  • Fractal Plant – Beta BuildFractal Plant – Beta Build
    April 24, 2022
Brandon Roots