How to control different stepper motors using a Rotary Encoder.



How to control different stepper motors using a Rotary Encoder.

OVERVIEW

Welcome to this multi part tutorial on how to control different stepper motors using a rotary encoder.

In this first part we will use the inexpensive and popular stepper motor that comes with it’s own control board. The 28BYJ-48 stepper motor with the ULN2003 board.

The 28BYJ-48 motor is not very fast or very strong, but it’s great for beginners to start experimenting with controlling a stepper motor with an Arduino.

We will write some code to have the motor move in the direction that we turn the rotary encoder, and will also keep track of how much steps we have taken, so that we can have the motor move back to the starting position by pressing down on the rotary encoder switch.


Stepper Motor with Rotary Encoder Schematic

We are using 4 pins to control the Stepper and 3 pins for the rotary encoder module.

Pin 8-11 are controlling the Stepper motor and pin 2-4 are receiving information from the rotary encoder.

We connect the 5V and Ground from to UNO to the rotary encoder and as a precaution, use a breadboard power supply to power the Stepper motor since it can use more power that the UNO can provide.

We also connect the UNO Ground to the breadboard to serve as a reference.

THE CODE

We are using the “Stepper” library to control the stepper motor.

The “Stepper” library is included by default with the Arduino Software install.

We are using some variables to store the current position, since we want to keep track of the position of the stepper motor so we can make it move back to the starting position.

We also included some error checking code to make sure that the rotary encoder is not missing steps, since that would make our motor position inaccurate.

Comments

Popular posts from this blog

Build Your Own Arduino Weather Station

Arduino ​Obstacle Avoiding Robot Ardunio Computer

Complete Guide for Nokia 5110 LCD with Arduino