Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Controlled Stepper Motor with Potentiometer Feedback

Image of Arduino-Controlled Stepper Motor with Potentiometer Feedback

Circuit Documentation

Summary

This circuit is designed to control a bipolar stepper motor using an Arduino UNO microcontroller. The motor's rotation is determined by the position of a rotary potentiometer. The Arduino reads the potentiometer's value and translates it into motor steps. A motor driver IC, the SN754410, is used to amplify the Arduino's control signals to drive the stepper motor. Power is supplied through a 2.1mm Barrel Jack with Terminal Block.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

Stepper Motor (Bipolar)

  • A bipolar stepper motor with four leads labeled A, B, C, and D.
  • It requires a dual H-bridge to drive it.

SN754410

  • Quadruple half-H driver IC
  • It is capable of driving high voltage/high current loads in positive-supply applications, which includes bipolar stepper motors.

Rotary Potentiometer

  • A three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider.
  • Resistance: 10,000 Ohms

2.1mm Barrel Jack with Terminal Block

  • A power connector that allows for external power sources to be connected to the circuit.

Wiring Details

Arduino UNO

  • 5V connected to the VCC Logic of SN754410 and leg2 of Rotary Potentiometer.
  • GND connected to the GND of SN754410, leg1 of Rotary Potentiometer, and NEG of the Barrel Jack.
  • A0 connected to the wiper of the Rotary Potentiometer.
  • D8 connected to 1 In of SN754410.
  • D9 connected to 2 In of SN754410.
  • D10 connected to 3 In of SN754410.
  • D11 connected to 4 In of SN754410.

Stepper Motor (Bipolar)

  • A connected to 1 Out of SN754410.
  • B connected to 3 Out of SN754410.
  • C connected to 2 Out of SN754410.
  • D connected to 4 Out of SN754410.

SN754410

  • 1,2 Enable, 3,4 Enable, and VCC Logic connected to 5V of Arduino UNO.
  • GND connected to GND of Arduino UNO.
  • VCC Motor connected to POS of the Barrel Jack.
  • 1 In, 2 In, 3 In, 4 In connected to corresponding pins D8, D9, D10, D11 on Arduino UNO.
  • 1 Out, 2 Out, 3 Out, 4 Out connected to corresponding leads A, B, C, D on Stepper Motor.

Rotary Potentiometer

  • leg1 connected to GND of Arduino UNO.
  • wiper connected to A0 of Arduino UNO.
  • leg2 connected to 5V of Arduino UNO.

2.1mm Barrel Jack with Terminal Block

  • POS connected to VCC Motor of SN754410.
  • NEG connected to GND of Arduino UNO.

Documented Code

/*
  Sketch to control a stepper motor with a potentiometer.
  A stepper motor follows the turns of a potentiometer (or other sensor) on analog input 0.
*/

#include <Stepper.h>

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

// 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, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 0;

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

void loop() {
  // get the sensor value
  int val = analogRead(0);

  // move a number of steps equal to the change in the
  // sensor reading
  stepper.step(val - previous);

  // remember the previous value of the sensor
  previous = val;
}

This code is designed to run on the Arduino UNO. It initializes the stepper motor with the specified number of steps and sets the motor speed. In the loop, it reads the analog value from the potentiometer connected to A0, calculates the difference from the previous reading, and moves the stepper motor accordingly. The previous sensor value is updated at the end of each loop iteration.