'Recognizing the need is the primary condition for design.'

Charles Eames

'To design is to communicate clearly by whatever means you can control or master.'
Milton Glaser

Stepper motor control with pot and LEDs

Components Required: 


1 X Stepper motor

1 X Stepper motor control board

1 X Potentiomter

3 X 10k resistors

1 X Red LED

1 X Green LED



1 X Micro controller board 

Wiring Instructions:

Use the instructions below with the image gallery to connect the components as follows:



5V + and - GND power from micro controller board to breadboard

1: Connect the 5V+ on the mega board to the + red rail on the breadboard, then connect the GND on the mega board to the - blue rail on the breadboard. 


Stepper Motor and Stepper motor board

2: Connect the + and - on the Stepper motor controler board to 5V+ and 0V- rails on the bread board


Stepper motor to Stepper motor board

2.1: Connect the 4 wire motor cable from the stepper motor into the ABCD connector of the stepper controller boards


2.2: Connect the IN1, IN2, IN3, IN4 connectors on the stepper motor control board to Pin2,3,4, and 5 on the micro controller board. 


Potentiometer / Variable resistor
3. Connect one terminal (left) of the potentiometer to +5V rail on the bread board, then connect the other terminal (right) of the potentiometer to the 0v- rail of the breadboard, then connect a resistor between the 0v- right terminal pin of the potentiometer. (this protects the potentiometer) 


Then, connect the 'wipe' (middle connector) of the potentiometer to analogue Pin A0 on the micro controller board. 



4: Connect the short - leg of the red and green resistors to the -0V rail of the breadboard, then connect the positive leg of the LEDs to the breadboard with a resistor before connecting the positive leg of the red LED from the breadboard to pin 13 and the positive leg of the green LED to pin 12 on the micro controller. 


Add the code below with the Arduino IDE compiler to your micro controler:

// See below for tutorial
//Includes the Arduino Stepper Library
#include <Stepper.h>
// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;
// Pin Definitions
#define RED_LED_PIN 13
#define GREEN_LED_PIN 12
#define IN1_PIN 2
#define IN2_PIN 3
#define IN3_PIN 4
#define IN4_PIN 5
// Variables
int potValue = 0;
int stepperDelay = 0;
Stepper myStepper = Stepper(stepsPerRevolution, IN1_PIN, IN2_PIN, IN3_PIN, IN4_PIN);
// Setup Function
void setup() {
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
  pinMode(IN3_PIN, OUTPUT);
  pinMode(IN4_PIN, OUTPUT);
// Loop Function
void loop() {
  // Read the potentiometer value
  potValue = analogRead(POTENTIOMETER_PIN);
  // Map the potentiometer value to the stepper delay
  stepperDelay = map(potValue, 0, 1023, 10, 100);
  // Turn on the appropriate LED based on the motor status
  if (stepperDelay > 30) {
    digitalWrite(RED_LED_PIN, HIGH);    // Motor is running
    digitalWrite(GREEN_LED_PIN, LOW);
  } else {
    digitalWrite(RED_LED_PIN, LOW);     // Motor is not running
    digitalWrite(GREEN_LED_PIN, HIGH);
Code for Stepper and Pot
Code for Stepper and Pot.rtf
Text document [68.6 KB]
Print | Sitemap
© Julian Kupper