Hello,
I am working on a few simple projects with my Arduino at the moment, but for some reason nothing is working at the moment.
I am simply trying to make a stepper motor make a full turn clockwise and another full turn on the other side.
I have two boards that both light up when connected and when the code is uploaded, the Pin 13 lights up like it should. So for now, seems like everything is working fine. However, none of the mechanical part is working. The stepper motor isn't moving at all, as if the Arduino was off. This is happening to both of my boards, I have tried using a different computer but the result was the same. Does anyone know how I could fix this please?
Thank you very much.
Here is the code I was using that was working perfectly last week.
int outPorts[] = {11, 10, 9, 8};
void setup() {
// set pins to output
for (int i = 0; i < 4; i++) {
pinMode(outPorts[i], OUTPUT);
}
}
void loop() {
// Rotate a full turn
moveSteps(true, 32 * 64, 2);
delay(1000);
// Rotate a full turn towards another direction
moveSteps(false, 32 * 64, 2);
delay(1000);
}
void moveSteps(bool dir, int steps, byte ms) {
for (int i = 0; i < steps; i++) {
moveOneStep(dir); // Rotate a step
delay(ms); // Control the speed
}
}
void moveOneStep(bool dir) {
// Define a variable, use four low bit to indicate the state of port
static byte out = 0x01;
// Decide the shift direction according to the rotation direction
if (dir) { // ring shift left
out != 0x08 ? out = out << 1 : out = 0x01;
}
else { // ring shift right
out != 0x01 ? out = out >> 1 : out = 0x08;
}
// Output singal to each port
for (int i = 0; i < 4; i++) {
digitalWrite(outPorts[i], (out & (0x01 << i)) ? HIGH : LOW);
}
}
Your Arduino is not a power supply. What are the specs of the stepper that you use; you might need an external power supply for the steppers.
Double check wiring.
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project See About the IDE 1.x category.
That's what I thought but I had the exact same wiring, code, power source last week and it did work. I had 3 people check it as well in case I missed something but they couldn't find anything wrong on code or wiring.
You haven't posted enough hardware details to answer those questions. The one Fritzing diagram you posted, has a lot of unlabelled devices, and doesn't show power connections at all.
I'm using a Arduino Uno, a ULN2003 stepper motor driver, this stepper motor (https://www.amazon.co.uk/gp/product/B07Y9PT7VJ/ref=ppx_yo_dt_b_asin_title_o08_s02?ie=UTF8&psc=1) and I'm powering the board through my computer with a USB cable. That's all there is and I have connected the wires exactly like they are in the diagram. Again, it worked very well last time but not anymore, and even with other projects I encounter the same problem: Arduino is on, seems to receive data, but nothing happens. I have had 3 people check with me as well but none of them knew what to tell me
I'm not sure what you mean. This is what I was using last week and it worked. I am just powering the board from my computer and that's how it was working before. I didn't use anything else so I'm confused on how this is incomplete as it's all I've used.
Also this particular issue is not the problem I think, as any other simple project doesn't seem to be working either
I think I know what was wrong. The blink didn't work when I was working in the studio. I tested blink again yesterday at home and the only thing that was different was the cable. So I definitely think it's the cable (from computer to arduino) that was the issue. I just wanted to post this last message in case someone had the same issue !