#define DIR_PIN 10 #define STEP_PIN 11 #define EN_PIN 15 // #define MS1 14 //micro step // #define MS2 13 //micro step int analogPin = 28; // potentiometer wiper (middle terminal) connected to analog pin GP28(pin nr 34/ADC2) // outside pins connected to GND and 3.3V int val = 0; // variable to store the value read void setup() { // put your setup code here, to run once: Serial.begin(115200); //step pin pinMode(10, OUTPUT); //direction pin pinMode(11, OUTPUT); digitalWrite(11, HIGH); //enable pin pinMode(15, OUTPUT); digitalWrite(15, LOW); //reading from the potentiometer //pinMode(26,INPUT); } void loop() { // put your main code here, to run repeatedly: val = analogRead(analogPin); // read the input pin Serial.print("Value:"); // value name Serial.println(val); // debug value //int potentiometer = analogRead(26); // Serial.println(potentiometer); //delay(1); oneStep(); delayMicroseconds(val); } void oneStep() { digitalWrite(STEP_PIN, HIGH); delayMicroseconds(1); digitalWrite(STEP_PIN, LOW); delayMicroseconds(50); }