Control Stepper Motor Using Joystick

by rayankiwan63 in Circuits > Arduino

3566 Views, 6 Favorites, 0 Comments

Control Stepper Motor Using Joystick

joystick control stepper.png

control stepper motor using joystick and arduino

Introduction

IMG_20210701_145153.jpg

In this project we want to control stepper motor using joystick and arduino uno

Components Needed

IMG_20210701_145153.jpg
Control stepper motor using joystick and arduino uno

1- arduino uno

2-stepper motor

3-ULN2003 stepper motor driver board

4- wires

5- breadboard

Programming Code

#include stepper.h

const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution

const int rolePerMinute = 15;

const int X_pin = 1; // analog pin connected to X output

Stepper myStepper(stepsPerRevolution, 2, 4, 3, 5);

void setup() { myStepper.setSpeed(rolePerMinute); //Serial.begin(9600);

}

void loop() {

// Serial.print("X-axis: ");

// Serial.println(analogRead(X_pin));

int a = analogRead(X_pin);

if (a > 400 && a < 520) {

for (int i = 2; i < 6; i++) { digitalWrite(i, LOW); } }

else if (a < 400)

{ myStepper.setSpeed(rolePerMinute);

myStepper.step(-30); }

else if (a > 530) { myStepper.setSpeed(rolePerMinute);

myStepper.step(30); }

}

Output Results

Control stepper motor using joystick and arduino uno

after uploading the code , and changing joystick position output results obtain