// motor ccw, cw, freewheel
// https://forum.arduino.cc/t/adjusting-speed-of-stepper-motor-with-potentiometer/1327873
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define potPin A0 // 10k
#define dirPin 8 // direction
#define stepPin 9 // step
#define enblPin 10 // enabled
#define freewheelLO 510
#define freewheelHI 1023 - freewheelLO
/*
0 - CCW 100%
449 - CCW 0% (DIR 0)
450 - STOP (ENBL LOW)
510 - Freewheel (ENBL HIGH)
514 - Freewheel (ENBL HIGH)
573 - STOP (ENBL LOW)
574 - CW 0% (DIR 1)
1023 - CW 100%
*/
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
pinMode (potPin, INPUT);
pinMode (dirPin, OUTPUT);
pinMode (stepPin, OUTPUT);
pinMode (enblPin, OUTPUT);
welcome();
}
void loop() {
int potVal = analogRead(A0);
}
void welcome() {
Serial.print("Move potentiometer to Freewheel (");
Serial.print(freewheelLO);
Serial.print(" to ");
Serial.print(freewheelHI);
Serial.println(") to start.");
while (analogRead(potPin) < freewheelLO || analogRead(potPin) > freewheelHI) {
lcd.setCursor(6, 0);
lcd.print(analogRead(A0));
};
lcd.setCursor(5,0);
lcd.print("Start");
// lcd.clear();
}