Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Controlled Stepper Motor with Rotary Potentiometer Speed Adjustment

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Stepper Motor with Rotary Potentiometer Speed Adjustment

Circuit Documentation

Summary

This circuit consists of an Arduino Nano microcontroller, a ULN2003A breakout board, a 28BYJ-48 stepper motor, and a rotary potentiometer. The Arduino Nano reads the analog value from the potentiometer and controls the stepper motor speed through the ULN2003A driver.

Component List

Arduino Nano

ULN2003A Breakout Board

28BYJ-48 Stepper Motor

Rotary Potentiometer

Wiring Details

Arduino Nano

ULN2003A Breakout Board

28BYJ-48 Stepper Motor

Rotary Potentiometer

Code Documentation

Arduino Nano Code

#include <Stepper.h>

const int stepsPerRevolution = 200;  
Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);
int stepCount = 0;  

void setup() {
}

void loop() {
   int sensorReading = analogRead(A0);
   int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
   if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    myStepper.step(stepsPerRevolution / 100);
  }
}

This code initializes a stepper motor with 200 steps per revolution. In the loop function, it reads the analog value from pin A0 (connected to the potentiometer), maps this value to a motor speed, and if the speed is greater than 0, it sets the motor speed and steps the motor.