///////////////////////////////////////////////////
/////////////////////// BIG NOTE //////////////////
// The Enable Button IS INVERTED /////////////////
///// HIGH means OFF/////////////////////////////
//// LOW means ON //////////////////////////////
#include <Stepper.h>
const int Dir = 0;
const int Step = 4;
const int steps_per_rev = 2000;
const int enable = 16;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(Dir, OUTPUT);
pinMode(Step, OUTPUT);
pinMode(enable , OUTPUT);
digitalWrite(enable, HIGH);
Serial.println("Enter 1 :");
}
void loop() {
if (Serial.available()) {
char command = Serial.read();
if (command == '1') {
with();
}
}
}
/////////////////////////////////////
void with() {
Serial.println("ONNNNNNNNNNNNNNNN");
digitalWrite(Dir, HIGH); // Clockwise
digitalWrite(enable, LOW);
for (int i = 0; i < steps_per_rev; i++) {
Serial.println("ONNNNNNNNNNNNNNNN");
digitalWrite(Step, HIGH);
delayMicroseconds(1000);
digitalWrite(Step, LOW);
delayMicroseconds(1000);
}
}
void counter(){
digitalWrite(Dir, LOW); // Counter Clockwise
for (int i = 0; i < steps_per_rev; i++) {
digitalWrite(Step, HIGH);
delayMicroseconds(1000);
digitalWrite(Step, LOW);
delayMicroseconds(1000);
}
}