This instruction describes how to control a stepper motor with a Raspberry Pi. The idea is to build a Raspberry Pi robot with four stepper motors. I bought a 28BYJ-48 stepper motor which could be controlled by a ULN2003A chip. The stepper motor and the controller board with the ULN2003A chip was sold together. That makes it very easy to hook up the stepper motor with the Raspberry Pi. You could not direct connect a stepper motor with the GPIO pins of the Raspberry Pi. If you do so you will damage your Raspberry Pi. The mAh the stepper needs to turn are too high for the GPIO pins of the Raspberry Pi. They only supply a few mAh.

The picture below shows the stepper motor controller and the stepper motor itself.

Stepper motor 28BYJ-48

Stepper motor 28BYJ-48

Components List

Raspberry Pi 3 Model B Kit

Vilros Raspberry Pi 3 Ultimate Starter Kit
Preis: EUR 79,99
1 neu von EUR 79,990 gebraucht
Get Your First Taste Of raspberry Pi with this Ultimate Starter Kit from Vilors.

This Is the Raspberry Pi 3 Model B Ultimate Starter Kit From Vilros
It includes the new Raspberry Pi 3 Model B (Latest Version Released on 02/29/2016)

Raspberry Pi 3 Model B Technical Specifications:
• Broadcom BCM2837 64bit ARMv8 Quad Core Processor powered SingleBoard Computer running at 1.2GHz
• BCM43143 WiFi on board
• Bluetooth Low Energy (BLE) on board
• 40pin extended GPIO
• 4 x USB2 ports
• 4 pole Stereo output and Composite video port
• Full size HDMI
• CSI camera port for connecting the Raspberry Pi camera
• DSI display port for connecting the Raspberry Pi touch screen display
• MicroSD port for loading your operating system and storing data
• Upgraded switched Micro USB power source (now supports up to 2.4 Amps)

Kit Content
Raspberry Pi 3- Model B 1GB
Raspberry Pi Enclosure Case (Clear)
32GB Micro SD Card pre-loaded with NOOB
SD Card Adapter
5-Foot EU Micro USB Power Supply 2500 mA
High Quality HDMI Cable
400-Tie-point breadboard (white)
65 Jumper Wires -- 45 pcs--100mm, 10 pcs--150mm, 5 pcs--200mm, 5 pcs--250mm
GPIO Ribbon Cable with Breakout board
45 X 330 Resistors
45X 10K Resistors
2X Big 12mm Buttons
Heatsink for Raspberry Pi - Set of 2 Heat Sinks
10X Yellow LED
10X Red LED

NOTE: The SD Card may appear to be a smaller capacity when you test it on your computer due to partitions placed on the card once the software is installed.

WEEE-Reg.-Nr. DE 29056374

Stepper motor kit 28BYJ-48

ROSENICE 5 Stücke Stepper Motor Schrittmotor 5V 28BYJ-48 ULN2003 + Treiberplatine ULN2003 für Arduino Professional
Preis: EUR 13,99
2 neu von EUR 13,990 gebraucht

Diese Schrittmotor ist mit eine Standardschnittstelle kommen direkt steckbar, wenn verwendet werden können. A, B, C, D vier-Phasen-LED zeigt den Status der Stepper motor arbeiten. 5 Zeile 4 Phase eignet sich für gewöhnliche ULN2003 Chip Treiber, verbinden Sie mit der 2-Phasen, dem Entwicklungsboard mit bequemen Gebrauch zu unterstützen und direkt andocken.


-Material: PCB Elektronikkomponenten.
-Größe: Ca. 14,5 * 9.2 * 4 cm / 5,7 * 3.6 * 1,6 Zoll (L * B * H).
-Nennspannung: DC5V 4-Phasen.
-Isolationswiderstand: andgt; 10MΩ (500V).
-Spannungsfestigkeit: 600 v AC / 1mA / 1 s.
-Schrittwinkel: 5.625 x 1/64.
-DC-Widerstand: 200Ω±7 % (25C).
-Untersetzung: 1/64.
-Isolierung Klasse: A.
-No-Load-Pull in Frequenz: andgt; 600Hz.
-Leerlauf herausziehen Frequenz: andgt; 1000Hz.
-Ziehen Sie in Drehmoment: andgt; 34.3mN.m(120Hz).
-Arretierung Drehmoment: andgt; 34.3mN.m.
-Temperatur Aufstieg: 《40K(120Hz).
-Mit einer standard Schnittstelle, direkt steckbar während des Gebrauchs.
-A, B, C, D vier-Phasen-LED zeigt den Status der Stepper motor arbeiten.
-Für gewöhnliche ULN2003-Chip-Treiber verwendet, verbinden Sie mit der 2-Phasen, unterstützen Sie das Development Board zu. Mit bequeme Nutzung direkt andocken.

Paket bestehend aus

5 Stellen Sie Uln2003 Stepper Motor + Treiber-Platine
10pcs weiblich zu männlich Kabel (als Geschenk)

Stepper motor Wiring

First connect the stepper motor with the motor controller. I used for this the supplied white plug. Then I connected the motor controller with the Raspberry Pi. I call this connection the logic connection because over the four wires the Raspberry Pi tells the motor controller how to control the stepper motor. You need four female-to-female jumper wires for the logic connection. The table below shows the pins from the stepper motor controller and the GPIO pins from the Raspberry Pi.

Stepper motor controller Raspberry Pi GPIO
IN1 6
IN2 13
IN3 19
IN4 26

The stepper motor controller has two additional pins for GND and VCC. I used a 5V power supply and connected those two pins with the Vout of the power supply. Now you are ready to test your setup with a small Python program.

Python test program

The Python test program is a small decision maker. It will turn the stepper motor randomly clockwise or counterclockwise. The steps the stepper motor will turn are also randomly calculated for each program run.

The program is available on GitHub in my repository: Stepper-motor-28BYJ-48-Raspberry-Pi

The result is a nice decision maker as you see in the picture below.

Decision Maker

The decision maker was easy to build. I draw a circle with eight decision and put the paper on top of the stepper motor. The next picture shows the decision maker.

decision maker

decision maker


This type of stepper motor is easy control with a Raspberry Pi. Bigger stepper motors which need more current need different motor controllers. But for a decision maker or a small robot the 28BYJ-48 stepper motor is strong enough.

(Visited 482 times, 1 visits today)