//int XrPin = 7; //int XsPin = 6; int YrPin = 5; int YsPin = 4; //int ZrPin = 3; //int Zspin = 2; const int Ystep_pin = 16; const int Ydir_pin = 17; int Yr_value = 0; int Ys_value = 0; int delayBetweenSteps = 100; void setup() { // put your setup code here, to run once: pinMode(Ystep_pin, OUTPUT); pinMode(Ydir_pin, OUTPUT); pinMode(YrPin, INPUT); pinMode(YsPin, INPUT); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: Yr_value = analogRead(YrPin); //reading Yr potentiometer int Yr_mapped = map(Yr_value, 0, 1023, 5000, 100); //converting value from potentiometer to value I want Serial.println(Yr_value);//printing serial by line Ys_value = analogRead(YsPin);//reading Ys potentiometer Serial.println(Ys_value); //printing serial by line if (Ys_value < 500) { //if Ys_value is more than 500 do this digitalWrite(Ydir_pin, HIGH); //Ys_direction pin to be rotate one way } else { //if anything eles digitalWrite(Ydir_pin, LOW); //Ys_direction pin to be rotate another way } digitalWrite(Ystep_pin, HIGH); delayMicroseconds(Yr_mapped); //using the value I set above as speed digitalWrite(Ystep_pin, LOW); delayMicroseconds(Yr_mapped); //Josep changed this //code avobe saying rotate in speed value from potentiometer }