Hi Guys.
Totally new to the forum and totally new to the Arduino scene and need a little help in my first project.
I have an Arduino Uno R3 (Elegoo) and Looking on control a Nema 17 Stepper motor using an a4988 driver with 2 dead man switches; for CW and CCW. Example: - Button one pressed and the stepper will move CW until the switch is released and the stepper will stop and same CCW.
Link to switch for reference: - Switch link
I have Wired up the Uno and the driver and I can send basic commands to make the stepper move one way and they the other so I know I have basic wiring connected right.
Art present, the pin setup is as below from the Uno: -
Pin -6: - Dir pin to stepper drv
Pin -5: - Step pin to stepper drv
Pin 4: - EN pin to stepper drv
Pin 5v: - login 5v to stepper drv
Pin gnd: - ground to stepper drv
Code is as per below I am running: -
int Index;
void setup()
{
pinMode(6, OUTPUT); //Enable
pinMode(5, OUTPUT); //Step
pinMode(4, OUTPUT); //Direction
digitalWrite(6,LOW);
}
void loop()
{
digitalWrite(4,HIGH);
for(Index = 0; Index < 2000; Index++)
{
digitalWrite(5,HIGH);
delayMicroseconds(1500);
digitalWrite(5,LOW);
delayMicroseconds(1500);
}
delay(1000);
digitalWrite(4,LOW);
for(Index = 0; Index < 2000; Index++)
{
digitalWrite(5,HIGH);
delayMicroseconds(1500);
digitalWrite(5,LOW);
delayMicroseconds(1500);
}
delay(1000);
}
I want to now add in the buttons but not too sure how to add in the code. I have seen that a pull down resistor is probably the best option but just want to find out from some people who has had experience with this before.
I hope I have given enough info and look forward to the replies.