Hello! I am trying to get a 5V 28BYJ-48 stepper motor with a ULN2003 driver to work with a joystick. I want it so that if the x value of the joystick is below a certain value, the stepper motor will turn for a certain amount of steps and if the joystick is above a certain value, it will turn opposite for the same amount of steps. I ran the stepper motor with test code and it works just fine, so the wiring is correct to my knowledge. Once I integrate it with the joystick, it doesn't turn anymore and just vibrates.
Right now I just have one x-direction coded just to test it out. Any help is appreciated! ![]()
//Includes the Arduino Stepper Library
#include <Stepper.h>
// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;
#define VRX_PIN A0
#define VRY_PIN A1
int xValue = 0;
int yValue = 0;
// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 1, 3, 2, 4);
void setup() {
Serial.begin(9600);
}
void loop() {
xValue = analogRead(VRX_PIN);
yValue = analogRead(VRY_PIN);
if(xValue < 200) {
myStepper.setSpeed(5);
myStepper.step(1000);
delay(1000);
}
}