Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include <Arduino.

h>
#include "BasicStepperDriver.h"
#define MOTOR_STEPS 200
#define RPM 500
boolean A = 0;
int flag = 0;
int val = 0;
#define MICROSTEPS 8

#define DIR A2
#define STEP A3
int state = 0;
BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);

void setup() {
stepper.begin(RPM, MICROSTEPS);
pinMode(9,INPUT_PULLUP);
}

void loop() {
A = digitalRead(9);
Serial.println(A);
if (A==1 && flag==0 && state == 0){
flag = 1;
}
if (A==1 && flag == 1 && state == 1){
flag = 0;
delay(1000);
state = 0;
}
if (flag==1 && A==0){
stepper.rotate(3414);
state = 1;
}}

You might also like