Hello, and thanks in advance for the help. I am using an UNO, programming with Arduino 1.5.6 r2. I am running 2, 28BYJ-48 stepper motors with their little 2PH640 H bridge drivers. I (barely) wrote a routine that runs the 2 motors back and forth around 1/2 revolution automatically. I want to add 4 buttons to my project to move each motor backward or forward with each button click. I will adjust the distance setting in the program to set the response to each press of the buttons. It would be desirable for the motors to run as long as the button is held down, but move the distance specified with a single click of the button. Below is my code, the i variable loop could be removed once the button routines are in place-----
include <Stepper.h>
#define STEPS 48 // 48 steps per rotation
Stepper stepper1f(STEPS, 11, 9, 10, 8); //open forward stepper A
Stepper stepper1r(STEPS, 8, 10, 9, 11); //open reverse stepper A
Stepper stepper2f(STEPS, 7, 5, 6, 4); //open forward stepper B
Stepper stepper2r(STEPS, 4, 6, 5, 7); //open reverse stepper B
void setup()
{
int i;
stepper1f.setSpeed(160); //set speed
stepper1r.setSpeed(160); //set speed
stepper2f.setSpeed(160); //set speed
stepper2r.setSpeed(160); //set speed
for (i=0;i<4;i++) {
stepper1f.step(1000); //distance
stepper1r.step(1000); //distance
stepper2f.step(1000); //distance
stepper2r.step(1000); //distance
}
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
void loop()
{}
I am not a software guy. My brain just is not wired for it. Im pretty good with hardware though. This particular project is 80's vintage wafer prober which uses a linear stepper motor XY stage, which is a pretty cool thing, gutted of its old electronics and replaced with an UNO running GRBL and using Universal Gcode sender and some modern stepper motor drivers. The prober now thinks its a CNC machine. The weakness of UGS is that it can only handle the 3 main axis, X,Y and Z. I also need Theta and tilt adjustment and dont want to run another copy of UGS to handle the theta and tilt. One or 2 dedicated UNO's with buttons should be fine for those fixed adjustments.
The UNO has 4 remaining digital IO channels and all of its analog IO. I hope one of you coders helps me, What would take me a week or more may only take you 15 minutes.
Thanks,
Gary