Close

Hello World with the TB6612 stepper driver

A project log for Fluid Commutator Assist

Motorized assist for fluid commutator

lex-kravitzLex Kravitz 07/27/2019 at 21:300 Comments

To control the stepper for this project we are using the TB6612 driver with a breakout board from Adafruit.  This breakout requires more wires than some other stepper drivers but it is simple to use and has some features that make this a good choice for this project.

Today I did the "Hello World" equivalent and set this chip up to turn a stepper, following the Adafruit tutorial.  I'm using a 5V stepper from Adafruit which is convenient because we can power it directly from the 5V pin of the Uno, instead of needing a separate 12V power supply.

I wired it up like the tutorial (photos below) and flashed the following code onto an Arduino Uno clone that I had lying around.  The stepper turns both ways, hello world!  

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 200

// create an instance of the stepper class, specifying the number of steps of the
// motor and the pins it's attached to
Stepper stepper(STEPS, 4, 5, 6, 7);

void setup() {
  stepper.setSpeed(30); // set the speed of the motor to 30 RPMs
}

void loop() {
  stepper.step(100);  // Move clockwise
  delay (1000); // Wait a second
  stepper.step(-100);  //Move counter-clockwise
  delay (1000); // Wait a second
}

Photos of the entire setup (I attached the red disk to the stepper to see it turn more easily)

Close-up of the TB6612 connections:

Discussions