#include <Button.h>
#define dirPin 2
#define stepPin 3
#define stepsPerRevolution 200
Button Abrir(12);
Button Cerrar(5);
const int stepDelay = 10000;
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
Abrir.begin();
Cerrar.begin();
}
void loop() {
// Set the spinning direction clockwise:
digitalWrite(dirPin, HIGH);
if (Abrir.pressed()){
for (int i = 0; i < 150; i++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(stepDelay);
digitalWrite(stepPin, LOW);
delayMicroseconds(stepDelay);
}
}
if (Cerrar.pressed()){
digitalWrite(dirPin, LOW);
for (int i = 0; i < 150; i++) {
digitalWrite(stepPin, LOW);
delayMicroseconds(stepDelay);
digitalWrite(stepPin, HIGH);
delayMicroseconds(stepDelay);
}
//delay(500);
//digitalWrite(dirPin, LOW);
//for (int i = 0; i < 150; i++) {
//digitalWrite(stepPin, HIGH);
//delayMicroseconds(stepDelay);
//digitalWrite(stepPin, LOW);
//delayMicroseconds(stepDelay);
}
}