Hi,
Relatively new to Arduino and have reached some difficulty during a project. Spent a while looking for solutions or help with this case but couldn't find any.
I am aiming to use an infrared remote to control multiple steppers using the Accelstepper library.
I have been able to use the IR remote to control a single stepper motor using the Stepper library and also control multiple steppers at once using the Accelstepper library, however when I try a combination the steppers do not operate. the LEDs on stepper3's driver board (as an example) runs through the following sequence, AB, AD, CD, BC, when the UP button is pressed but never all four at once.
The code which I am using is as follows:
#include <AccelStepper.h>
#include <IRremote.h>
AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 6, 7, 8, 9);
AccelStepper stepper3(AccelStepper::FULL4WIRE, 10, 11, 12, 13);
int receiver = A3; //IR reciever pin
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
Serial.begin(9600);
stepper1.setMaxSpeed(300.0);
stepper1.setAcceleration(100.0);
stepper1.moveTo(1000000);
stepper2.setMaxSpeed(300.0);
stepper2.setAcceleration(100.0);
stepper2.moveTo(-1000000);
stepper3.setMaxSpeed(300.0);
stepper3.setAcceleration(100.0);
stepper3.moveTo(1000000);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 0xFF629D: // UP button pressed
stepper1.run();
stepper3.run();
case 0xFFA857: // DOWN button pressed
stepper2.run();
stepper3.run();
}
irrecv.resume(); // receive the next value
}
}
Any solutions or help on what I'm doing wrong would be much appreciated,
Thanks.