Τελικα δοκιμαζοντας διαφορα μεσα στο κωδικα βρηκα ενα τροπο να κανω αυτο που θελω
Στο τελος της διαδικασιας του μηδενισμου οταν χτυπά το διακοπτη οριου σταματα και κανει τα αποραιτητα βηματα πποσ τα πισω για να ελευθερωση
τον διακοπτη οριου και εθετε την τρεχουσα θεση στο μηδεν.
Αλαξα λοιπον την τρεχουσα θεση απο 0 σε 600 και παιρνει τιμη 300 τωρα γιατι παιρνει την μιση τιμη δεν το γνωριζω αλλα θα το ψαξω
Κώδικας:
while (digitalRead(Home_Switch)) { // Make the Stepper move CCW until the switch is activated
digitalWrite(RedLed, HIGH);
stepper.moveTo(initial_homing); // Set the position to move to
initial_homing--; // Decrease by 1 for next move if needed
stepper.run(); // Start moving the stepper
digitalWrite(RedLed, HIGH);
delay(5);
}
stepper.setCurrentPosition(0); // Set the current position as zero for now
stepper.setMaxSpeed(100.0); // Set Max Speed of Stepper (Slower to get better accuracy)
stepper.setAcceleration(50.0); // Set Acceleration of Stepper
initial_homing=1;
while (!digitalRead(Home_Switch)) { // Make the Stepper move CW until the switch is deactivated
stepper.moveTo(initial_homing);
stepper.run();
initial_homing++;
digitalWrite(RedLed, LOW);
digitalWrite(GreenLed, HIGH);
}
delay(10);
digitalWrite(sol, LOW);
stepper.setCurrentPosition(600); //<======Αλαγη απο 0 σε 600
currentposition="300";