How to Interface Stepper Motor with 8051 Advanced Development Board

Stepper Motor Interfacing With 8051 Slicker

Tags: Interfacing stepper motor with 8051,8051 source code for stepper motor,Circuit Diagram to Interface Stepper Motor with 8051, C Program to control stepper motor using 8051,
Overall rating
8051 Slicker Board

The 8051 Advanced Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Advanced Development Board is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

Stepper Motor

A stepper motor is a brushless, synchronous electric motor that converts digital pulses into mechanical shaft rotation. Every revolution of the stepper motor is divided into a discrete number of steps, and the motor must be sent a separate pulse for each step.

Interfacing Stepper Motor

Fig. 1 shows how to interface the Stepper Motor to microcontroller. As you can see the stepper motor is connected with Microcontroller output port pins through a ULN2003 array. So when the microcontroller is giving pulses with particular frequency to ULN2003, the motor is rotated in clockwise or anticlockwise.


Fig. 1 Interfacing Stepper Motor to Microcontroller

Interfacing Stepper Motor with 8051

We now want to control a stepper motor in 8051 Slicker Board. It works by turning ON & OFF a four I/O port lines generating at a particular frequency.

The 8051 Slicker board has four numbers of I/O port lines, connected with I/O Port lines (P2.0 – P2.3) to rotate the stepper motor. ULN2003 is used as a driver for port I/O lines, drivers output connected to stepper motor, connector provided for external power supply if needed.

Pin Assignment with 8051



Stepper Motor(5V)

8051 Lines

Stepper Motor PWR Select











Make  switch SW30 to SM/RL label

marking position.



Circuit Diagram to Interface Stepper Motor with 8051


Source Code

The Interfacing stepper motor control with 8051 program is very simple and straight forward, that control the stepper motor in clockwise, counter clockwise and also a particular angular based clockwise by using switches. The I/O port lines are used to generate pulses for stepper motor rotations. C programs are written in Keil software.

C Program to control stepper motor using 8051


Title : Program to control stepper motor rotations




#include <reg51.h>                     //Define 8051 registers



void DelayMs(unsigned int);                 //Delay function


//  Main Program


void main (void)


    P2 = 0;                            //Initialize Port2

       while(1)                           //Loop Forever


         P2 = 0x01;DelayMs(20);         //Delay 20msec

         P2 = 0x02;DelayMs(20);

         P2 = 0x04;DelayMs(20);

         P2 = 0x08;DelayMs(20);




//       Delay Function


void DelayMs(unsigned int n)


unsigned int i,j;







Join the World's Largest Technical Community

we respect your privacy.