Published © LGPL

Grove Starter Kit For Arduino --- Stepper Motor & Driver

Teaches you how to use the Stepper motor and driver in the Arduino Grove Starter Kit.

BeginnerProtip30 minutes18,009
Grove Starter Kit For Arduino --- Stepper Motor & Driver

Things used in this project

Hardware components

Arduino 101
Arduino 101
×1
Seeed Studio SeeedStudio grove starter kit Arduino 101
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Stepper motor setup

Full setup with potentiometer, driver, and motor

Close up on ports

Close up on motor and driver

driver connections

Code

Stepper Code

Arduino
adjust the potentiometer to change the speed of the Motor
#include <Stepper.h>
int t =0;
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0;  // number of steps the motor has taken

void setup() {
  Serial.begin(9600);
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 25:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 25);
  // set the motor speed:
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 25);
  Serial.println(motorSpeed);//print how fast the motor is going in the serial monitor
  }
}

Credits

Comments