there and back again
parent
bffe353b21
commit
2a98ecfb21
17
src/main.cpp
17
src/main.cpp
|
@ -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(" ");
|
||||
|
|
Loading…
Reference in New Issue