Arduino Stepper Motor 28byj-48 Control Speed And Direction

About the project

In this tutorial we will learn how to move a stepper motor, change the speed with the potentiometer and change the direction using a button.

Project info

Difficulty: Easy

Platforms: ArduinoDFRobotSeeed StudioVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

DFRobot Gravity:Digital Push Button (Yellow) DFRobot Gravity:Digital Push Button (Yellow) x 1
Arduino UNO Arduino UNO x 1
Breadboard (generic) Breadboard (generic) x 1
Jumper wires (generic) Jumper wires (generic) x 1
Potentiometer, Slide Potentiometer, Slide x 1
Seeed Studio Gear Stepper Motor Driver Pack Seeed Studio Gear Stepper Motor Driver Pack x 1

Software apps and online services

Visuino Visuino
Arduino IDE Arduino IDE

Story

Step 1: What You Will Need

1 / 7

  • Arduino UNO (Or any other Arduino)
  • Stepper motor 28byj-48 & stepper motor driver board
  • Button
  • 1k ohm resistor
  • Potentiometer module
  • Jumper wires
  • Breadboard
  • Visuino program: Download Visuino

Step 2: 

Step 3: The Circuit

  • Connect Stepper Motor to Stepper Motor Driver
  • Connect Arduino pin [5V] to Driver Board pin [VCC]
  • Connect Arduino pin [GND] to Driver Board pin [GND]
  • Connect Arduino digital pin [8] to Driver Board pin [IN1]
  • Connect Arduino digital pin [9] to Driver Board pin [IN2]
  • Connect Arduino digital pin [10] to Driver Board pin [IN3]
  • Connect Arduino digital pin [11] to Driver Board pin [IN4]
  • Connect Arduino pin [5V] to breadboard positive pin [Red line]
  • Connect Arduino pin [GND] to breadboard negative pin [Black line]
  • Connect Arduino Digital pin [2] to the Resistor and button
  • Connect other side of the resistor to the breadboard pin [GND]
  • Connect Other pin of the button to the breadboard positive pin [5V]
  • Connect potentiometer pin [DTA] to arduino analog pin [A0]
  • Connect potentiometer pin [VCC] to the breadboard positive pin [5V]
  • Connect potentiometer pin [GND] to the breadboard pin [GND]

Step 4: Start Visuino, and Select the Arduino UNO Board Type

1 / 2

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

Step 5: In Visuino Add Components

1 / 4

  • Add "4 Wire Stepper Motor" component
  • Add "Debounce Button" component
  • Add "Toggle(T) Flip-Flop" component
  • Add "Map Range Analog" component

Step 6: In Visuino Set Components

1 / 3

  • Select "MapRange1" and in the properties window set "Output Range" > "Max" to 500 <<this will be the maximum steps per second
  • Select "Stepper1" and in the properties window select "Reversed" & click on the pin icon and select "Boolean SinkPin" and select "Steps Per Second" & click on the pin icon and select "Float SinkPin"

Step 7: In Visuino Connect Components

  • Connect Arduino Digital pin [2] to "Button1" pin [In]
  • Connect Arduino Analog pin [0] to "MapRange1" pin [In]
  • Connect "Button1" pin [Out] to "TFlipFlop1" pin [Clock]
  • Connect "TFlipFlop1" pin [Out] to "Stepper1" pin [Reversed]
  • Connect "MapRange1" pin [Out] to "Stepper1" pin [Steps Per Second]
  • Connect "Stepper1" pin [0] to Arduino digital pin [8]
  • Connect "Stepper1" pin [1] to Arduino digital pin [9]
  • Connect "Stepper1" pin [2] to Arduino digital pin [10]
  • Connect "Stepper1" pin [3] to Arduino digital pin [11]

Step 8: Generate, Compile, and Upload the Arduino Code

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Step 9: Play

If you power the Arduino module, The motor will do will start to run and with the potentiometer you can change the speed. If you press the button the motor will change the direction.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu

Schematics, diagrams and documents

Visuino File

Code

Visuino File

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...