there and back again

main
radex 2023-01-20 08:59:12 +01:00
parent bffe353b21
commit 2a98ecfb21
1 changed files with 12 additions and 5 deletions

View File

@ -97,6 +97,7 @@ void setup() {
bool shaft = false;
unsigned int stepsDelay = 28000 / MICROSTEPS;
bool shouldRun = true;
int stepsMade = 0;
void loop() {
if (Serial.available()) {
@ -152,21 +153,27 @@ void loop() {
}
if (shouldRun) {
if (stepsMade >= STEPS_PER_REV) {
stepsMade = 0;
shaft = !shaft;
driver.shaft(shaft);
}
for (uint32_t i = 100; i>0; i--) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(5);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(stepsDelay);
// if (digitalRead(DIAG_PIN) == HIGH) {
// Serial.println("STALL");
// }
}
stepsMade += 100;
if (driver.SG_RESULT() > 105) {
shaft = !shaft;
driver.shaft(shaft);
}
// if (driver.SG_RESULT() > 105) {
// shaft = !shaft;
// driver.shaft(shaft);
// }
// Serial.println(driver.SG_RESULT(), DEC);
// Serial.print(" ");