I cannot get this to work. All that happens is that the driver chip gets hot. With a 12v power supply, I got different results, but the controller and the motor were getting hot. I have no downgraded the supply to a 5v 600ma power supply, but all that happens is that the ULN2003 chip gets hot. I've downloaded and tried different code to no avail. I'm new to coding and hardware. Any assistance will be appreciated.
Stepper 28BYJ-48 connected to ULN2003
ULN 2003 to Uno - pins
IN 1 - 11
IN 2 - 10
IN 3 - 9
IN 4 - 8
ULN ->
5 power directly from external 5v 600ma power supply
onto breadboard daisy chained to GND on UNO board
Joystick HW-504
onto breadboard daisy chained to UNO 5v
GND onto Uno GND
VRX onto UNO A0
VRY onto UNO A1
Uno powered by computer USB
Code loaded on Uno NOT MY CODE I cant code
// include Arduino stepper motor library
#include <Stepper.h>
// define number of steps per revolution
#define STEPS 32
// define stepper motor control pins
#define IN1 8
#define IN2 10
#define IN3 9
#define IN4 11
// initialize stepper library
Stepper stepper(STEPS, IN4, IN2, IN3, IN1);
// joystick pot output is connected to Arduino A0
#define joystick A0
void setup()
{
}
void loop()
{
// read analog value from the potentiometer
int val = analogRead(joystick);
// if the joystic is in the middle ===> stop the motor
if( (val > 500) && (val < 523) )
{
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
else
{
// move the motor in the first direction
while (val >= 523)
{
// map the speed between 5 and 500 rpm
int speed_ = map(val, 523, 1023, 5, 500);
// set motor speed
stepper.setSpeed(speed_);
// move the motor (1 step)
stepper.step(1);
val = analogRead(joystick);
}
// move the motor in the other direction
while (val <= 500)
{
// map the speed between 5 and 500 rpm
int speed_ = map(val, 500, 0, 5, 500);
// set motor speed
stepper.setSpeed(speed_);
// move the motor (1 step)
stepper.step(-1);
val = analogRead(joystick);
}
}
}
Stepper motors do get hot, that's normal.
The 5volt version draws about 350mA, which is 1.75 watt.
If want less heat (at reduced torque), the drive the motor in single-coil mode.
Leo..
Thanks. After reading your comments, I tried another ULN2003 board with the 12v and it popped so that clearly was a 5v board
I've been running the ULN with the 12v controller today. However I cannot get the motor to do what I'm trying to achieve with the joystick, which is forward turn one way continously while holding the joystick in the forward position, backward turn the opposite way while holding the joystick in the backward position. Middle do nothing (switch off basically). I spent the afternoon trying various things with ChatGPT which gave me numerous things to try, to no avail. What we did stick on was that the joystick at resting (centre is giving a value of 1023, which according to ChatGPT should be 512? In any event, I am attaching photos of the setup and code. Hopefully someone will be able to assist. Thank you
// include Arduino stepper motor library
#include <Stepper.h>
// define number of steps per revolution
#define STEPS 32
// define stepper motor control pins
#define IN1 11
#define IN2 10
#define IN3 9
#define IN4 8
// initialize stepper library
Stepper stepper(STEPS, IN4, IN2, IN3, IN1);
// joystick pot output is connected to Arduino A0
#define joystick A0
//Define deadband for joystick
const int deadband = 20; //Adjust this value as needed
void setup() {
//Set motor control pins as output
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
}
void loop() {
// read analog value from the potentiometer
int val = analogRead(joystick);
//Apply deadband
if (val > 512 + deadband) {
// Move the motor in the forward position
int speed_ = map(val, 512 + deadband, 1023, 5, 100); //Adjust max
//speed as needed
stepper.setSpeed(speed_);
stepper.step(1); //Move one step forward
}
else if (val < 512 - deadband) {
//Move the motor in the backward direction
int speed_ = map(val, 0, 512 - deadband, 5, 100); //Adjust max
//speed as needed
stepper.setSpeed(speed_);
stepper.step(-1); //Move one step backward)
}
else {
//If joystick is centered, stop the motor
stepper.setSpeed(0);
}
}
Please also tell me where/how is the best way to learn the coding language? Through the IDE or is there another way for beginners?
Thank you
FYI The current code has the following result:
Centre position, All four lights on the ULN flash and the drive is turning clockwise (slowly
Foward position the lights flash in sequence and the motor slows down to the point where it isnt clear whether its actually turning.
Backward position lights stay aluminated, and the motor stop turning. (But is still very hot). Seems hotter then it should be.
Ive tried another joystick with the same result. 1 thing I'm not sure of; it the problem possibly that the ULN is a 12v and the motor is a 5v? Both the ULN and the joystick are powered from the 12v external supply. Any assistance will be appreciated.
Disconnect the motor plug from the ULN. Measure the resistance between the motor's RED wire and one of the other wires. If it's around 25 Ohms, you have a 5 volt motor. If 130 ~ 150 Ohms, it's a 12 volt motor.
If you are supplying 12V to the Vcc pin on the ULN2003 board and you have the jumper installed as shown in your earlier images, your 5V motor is getting 12V. That will kill the motor. And if it fails shorted, there goes your ULN2003 as well.
Since you have a 5V motor, there is no point, none, in supplying 12V to the ULN2003 board.
Thanks. I tried to draw a schematic using one of the online tools, but I can find the exact components. I'm guessing I have clone products in conjunction with not knowing what I'm doing which is why I am struggling. (The two wires going out the screen are going to the external power supply). The only one to yield results is the 12v supply. With the 5v supply, nothing happens. Current problems: Code and jostick not getting the motor to do what I'm trying to achieve. Push forward, turn one way, pull backward, turn the opposite way. (Idle in the middle). The further I push or pull from the centre point, the speed/power must increase. Joystick model HW-504. Any direction will be appreciated.