How to control a stepper motor
In this project you will learn how to control a stepper motor using the ATMEL328 board and the L293D motor control chip. The stepper motor can be turned left or right with a slide switche .
To build the project , you will need the following parts:
Schematic and board
The stepper motor is connected to the L293 IC, which is controlled by the ATMEGA328 board with PORTC. A slide switch is connected to the PORTD of the ATMEGA328 board. The switch drives the stepper motor to the left or to the right. The circuit is build on a breadboard
The code is written with the WINAVR C- compiler. The speed can be controlled with the speed parameter.
// program name: stepper
void left(int step_speed)
void right(int step_speed)
void stepper(int speed, int steps)
if (steps > 0)
int main (void)
int speed = 10;