/*A4988 Arduino Bipolar Stepper Motor Controller*/
#define STEP 6
#define DIR 5
#define TSCCW 11
#define TSACW 12
void pulseStep(void);
void setup() {
pinMode(STEP, OUTPUT);
pinMode(DIR, OUTPUT);
pinMode(TSCCW, INPUT_PULLUP);
pinMode(TSACW, INPUT_PULLUP);
}
void loop() {
if(digitalRead(TSCCW) == LOW) {
while( digitalRead(TSCCW) == LOW );
digitalWrite(DIR, HIGH);
pulseStep();
}
if(digitalRead(TSACW) == LOW) {
while( digitalRead(TSACW) == LOW );
digitalWrite(DIR, LOW);
pulseStep();
}
}
void pulseStep(void) {
digitalWrite(STEP, HIGH);
delay(50);
digitalWrite(STEP, LOW);
delay(50);
}