This tutorial is part of: Lesson 107 28BYJ-48 Stepper 8 Projects
This video has 8 projects. Each project has separate code.
Lesson 107-1: Start and Stop the 28BYJ-48 Stepper Motor with Direction Set in Code
Project 1: Basic Motor Control – 28BYJ-48 Stepper Motor
This article is part of a comprehensive video tutorial that demonstrates 8 practical projects using the 28BYJ-48 stepper motor. Each project highlights a different method of controlling the motor, from simple logic to serial communication and user interfaces. The source code and wiring diagrams for each project are provided below this article for your reference and implementation.
🔧 Introduction
The 28BYJ-48 stepper motor is a popular, low-cost motor often used in embedded systems, IoT projects, and automation tasks. This first project provides a foundation by demonstrating basic motor control: how to rotate the stepper motor forward and backward using Arduino code.
This serves as the building block for more advanced projects covered in the series.
âš™ï¸ Wiring Diagram
The wiring for Project 1 is straightforward. The 28BYJ-48 stepper motor is connected to the ULN2003 driver board, which then interfaces with an Arduino Uno as follows:
IN1 → Arduino pin 8
IN2 → Arduino pin 9
IN3 → Arduino pin 10
IN4 → Arduino pin 11
5V and GND from Arduino to ULN2003
Caption: Wiring diagram for Project 1: Basic Motor Control using ULN2003 driver.
💻 Code Explanation
This project uses the Stepper library included with the Arduino IDE. The core logic is as follows:
Library Import and Constants:
#include <Stepper.h>
const int stepsPerRevolution = 2048;Stepper Object Initialization:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);Note the pin order matches the motor coil sequence for smooth operation.
Setup Function:
void setup() {
myStepper.setSpeed(10);
Serial.begin(9600);
}Sets speed to 10 RPM.
Starts the serial monitor for debugging.
Loop Function:
void loop() {
myStepper.step(stepsPerRevolution); // Forward rotation
delay(1000);
myStepper.step(-stepsPerRevolution); // Reverse rotation
delay(1000);
}The motor turns one full revolution forward, then backward.
This simple control logic helps verify motor operation and wiring integrity.
🎬 Timestamps from Full Video
For in-depth visual guidance, refer to the following points in the full video:
00:00 – Start
02:03 – Introduction to stepper motor
07:40 – How motor is controlled
13:08 – Wiring explained
15:43 – Project 1 code
20:12 – Project 1 demonstration
📠Download Section
Links to the complete source code and wiring diagrams for this project are provided below this article.
Stay tuned for [Project 2: Controlling Stepper Motor via Serial Monitor] where we expand functionality through user interaction in the Arduino Serial Monitor.
This tutorial is part of: Lesson 107 28BYJ-48 Stepper 8 Projects
- Lesson 107-2: Controlling a 28BYJ-48 Stepper Motor via Serial Monitor
- Lesson 107-3: Controlling a 28BYJ-48 Stepper Motor Using Three Push Buttons: CW, CCW, and Stop (STPB-1)
- Lesson 107-4: Controlling a 28BYJ-48 Stepper Motor Using Two Push Buttons, CW, CCW (Keep Pressed), STPB-2
- Lesson 107-5: Send 28BYJ-48 Motor for One Revolution in CW or CCW Direction, STPB-3
- Lesson 107-6: Controlling a 28BYJ-48 Stepper Motor Using Three Push Buttons, with Angle and Speed STPB-4
- Lesson 107-7: Sending a 28BYJ-48 Stepper Motor to Any Angle with Defined STPB-5 Push Buttons
- Lesson 107-8: Controlling the Speed of a 28BYJ-48 Stepper Motor Using a Potentiometer
|||您可能需要的东西
-
全球速卖通Purchase 5 pcs 28BYJ-48 stepper motors from AliExpresss.click.aliexpress.com
资源与参考
-
外部Purchase 5 pcs 28BYJ-48 stepper motors from AliExpresss.click.aliexpress.com
文件📁
没有可用的文件。