Arduino Nano-Controlled 28BYJ-48 Stepper Motor with ULN2003A Driver and Potentiometer Speed Adjustment
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a 28BYJ-48 Stepper Motor using an Arduino Nano microcontroller and a ULN2003A breakout board. The speed of the stepper motor is regulated by a rotary potentiometer, which provides analog input to the Arduino Nano to set the motor speed. The Arduino Nano controls the stepper motor through the ULN2003A driver, which amplifies the control signals to drive the motor coils.
Component List
Arduino Nano
- Microcontroller board based on the ATmega328P
- It has a variety of digital and analog I/O pins
- Used as the main controller for the circuit
ULN2003A Breakout Board
- A driver board that contains the ULN2003A Darlington transistor array
- It is used to amplify the control signals from the Arduino Nano to drive the stepper motor
28BYJ-48 Stepper Motor
- A small, 5-wire, unipolar stepper motor
- It is driven by the ULN2003A breakout board to perform precise rotational movements
Rotary Potentiometer
- A variable resistor with a 10k Ohm resistance
- Provides analog input to the Arduino Nano to control the motor speed
Wiring Details
Arduino Nano
D8connected to ULN2003A breakout boardIn 1D9connected to ULN2003A breakout boardIn 2D10connected to ULN2003A breakout boardIn 3D11/MOSIconnected to ULN2003A breakout boardIn 4GNDconnected to ULN2003A breakout board0Vand Rotary Potentiometerleg25Vconnected to ULN2003A breakout board+5VVINconnected to Rotary Potentiometerleg1A0connected to Rotary Potentiometerwiper
ULN2003A Breakout Board
In 1toIn 4connected to corresponding Arduino Nano pinsD8toD11/MOSI0Vconnected to Arduino NanoGND+5Vconnected to Arduino Nano5VBLUE wireconnected to 28BYJ-48 Stepper MotorBLUEPINK wireconnected to 28BYJ-48 Stepper MotorPINKYELLOW wireconnected to 28BYJ-48 Stepper MotorYELLOWORANGE wireconnected to 28BYJ-48 Stepper MotorORANGERED wireconnected to 28BYJ-48 Stepper MotorRED
28BYJ-48 Stepper Motor
BLUEconnected to ULN2003A breakout boardBLUE wirePINKconnected to ULN2003A breakout boardPINK wireYELLOWconnected to ULN2003A breakout boardYELLOW wireORANGEconnected to ULN2003A breakout boardORANGE wireREDconnected to ULN2003A breakout boardRED wire
Rotary Potentiometer
leg1connected to Arduino NanoVINwiperconnected to Arduino NanoA0leg2connected to Arduino NanoGND
Documented Code
#include <Stepper.h>
const int stepsPerRevolution = 200; // number of steps per revolution for the motor
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); // initialize stepper library for the motor
int stepCount = 0; // number of steps the motor has taken
void setup() {
// Nothing to do here
}
void loop() {
int sensorReading = analogRead(A0); // read the value from the potentiometer
int motorSpeed = map(sensorReading, 0, 1023, 0, 100); // map it to a range from 0 to 100
if (motorSpeed > 0) {
myStepper.setSpeed(motorSpeed); // set the motor speed
myStepper.step(stepsPerRevolution / 100); // move the motor a fixed number of steps
}
}
The code is written for the Arduino Nano and is responsible for reading the analog input from the rotary potentiometer connected to pin A0. The reading is then mapped to a motor speed range and used to set the speed of the stepper motor. The stepper motor is controlled via the ULN2003A breakout board, which is connected to the Arduino Nano digital pins D8 to D11/MOSI. The Stepper library is used to simplify the control of the stepper motor.