Hello,
after a lot of reading i ended with the following program that fit my needs at the moment.i need to control a stepper front and back with a push of a button.simple!!!
my question is that i actually need 2 steppers.working with their own buttons for front and back.How can i add another stepper and another two buttons in the program??
As i sayed im completely new to arduino and prgramming.So please keep it dad simple.
#include <Stepper.h>
int clockwise= 2;
int anticlockwise= 3;
int enable=8;
Stepper motor(200, 10,11,12,13);
void setup() {
pinMode(clockwise,INPUT);
pinMode(anticlockwise,INPUT);
pinMode(enable,OUTPUT);
Serial.begin(9600);
}
void loop() {
int forward = digitalRead(clockwise);
int reverse = digitalRead(anticlockwise);
digitalWrite(enable,LOW);
if(forward == 1 && reverse == 0 ){
digitalWrite(enable,HIGH);
motor.step(1);
motor.setSpeed(60);
delay(.01);
}
if(reverse == 1 && forward == 0 ){
digitalWrite(enable,HIGH);
motor.step(-1);
motor.setSpeed(60);
delay(.01);
}
delay(5);
Serial.println(60);
}