In this tutorial we will learn how to move a stepper motor for a certain amount of steps, and then with a push of a button repeat it again.
Watch the Video!
Also: Check out the Arduino Nano and Visuino: Control Stepper Motor Tutorial With Buttons made by Boian Mitov
Step 1: What Will You Need
- Stepper motor 28byj-48 & stepper motor driver board
- Button module
- Arduino or any other board
- Visuino software: Download Visuino
Step 2: 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 [4] to Driver Board pin [IN1]
- Connect Arduino digital pin [5] to Driver Board pin [IN2]
- Connect Arduino digital pin [6] to Driver Board pin [IN3]
- Connect Arduino digital pin [7] to Driver Board pin [IN4]
- Connect Button module pin [Out] to Arduino digital pin [2]
- Connect Arduino pin [5V] to Button module pin [VCC]
- Connect Arduino pin [GND] to Button module pin [GND]
Step 3: Start Visuino, and Select the Arduino UNO Board Type
The Visuino: https://www.visuino.eu also needs to be installed. Download Free version or register for a Free Trial.
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 4: In Visuino Add & Set Components
- Add “Debounce Button” component
- Add “Pulse Generator” component
- Add “Up/Down Counter” component
- Add “4 Wire Stepper Motor” component
- Select “PulseGenerator1” and in the properties window set Frequency to 100, this will be the speed of the motor, you can adjust the number if you want.
- Select “UpDownCounter1” and in the properties window set Initial Value to 1000, this is the amount of the steps that the motor will do once you Turn “On” the Arduino.
Set the Min > “Value” to 0 and “Roll Over” to FalseThis means that the Counter will count down from 1000 to zero and once it reaches zero it will not roll over and start again.
- Connect “PulseGenerator1” pin [Out] to “UpDownCounter1” pin [Down]
- Connect “Button1” pin [Out] to “UpDownCounter1” pin [Reset]
- Connect “UpDownCounter1” pin [Out] to “Stepper1” pin [In]
- Connect “Stepper1” pin [0] to Arduino digital pin [4]
- Connect “Stepper1” pin [1] to Arduino digital pin [5]
- Connect “Stepper1” pin [2] to Arduino digital pin [6]
- Connect “Stepper1” pin [3] to Arduino digital pin [7]
- Connect Arduino Digital pin [2] to “Button1” pin [In]
Step 5: 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 7: Play
If you power the Arduino module, The motor will do 1000 steps and if you press a button it will do another 1000 steps.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it and open it in Visuino: https://www.visuino.eu
Download stepper-certain-steps.zip