Stepper: Demo

main
radex 2024-02-14 19:33:16 +01:00
parent 534d11741c
commit 1233d07a1c
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
4 changed files with 11 additions and 16 deletions

View File

@ -30,6 +30,6 @@
// --- Z axis motor
#define STEPPER_ENABLE 8
#define STEPPER_DIR 9
#define STEPPER_STEP 10
#define STEPPER_ENABLE 10
#define STEPPER_DIR 8
#define STEPPER_STEP 9

View File

@ -29,8 +29,6 @@ void setup() {
void loop() {
debugScanI2C();
// demoScreen();
// demoStepper();
demoTimer();
auto key = handleKeyboard();
@ -54,7 +52,7 @@ void loop() {
sadBuzz();
} else if (key == KEY_C) {
beep();
} else if (key == KEY_D) {
} else {
tick();
}
}
@ -67,5 +65,6 @@ void loop() {
if (auto event = handleEncoder()) {
tick();
Serial.println(event == ENCODER_CLOCKWISE ? "Clockwise" : "Counter-clockwise");
demoStepper(event == ENCODER_CLOCKWISE ? LOW : HIGH);
}
}

View File

@ -10,16 +10,12 @@ void setupStepper() {
digitalWrite(STEPPER_ENABLE, LOW);
}
bool stepperDir = HIGH;
void demoStepper() {
Serial.println("Demoing stepper motor - rotating 200 steps");
stepperDir = !stepperDir;
digitalWrite(STEPPER_DIR, stepperDir);
for (int i = 0; i < 200; i++) {
void demoStepper(bool dir) {
digitalWrite(STEPPER_DIR, dir);
for (int i = 0; i < 3200; i++) {
digitalWrite(STEPPER_STEP, HIGH);
delay(2);
delayMicroseconds(25);
digitalWrite(STEPPER_STEP, LOW);
delay(7);
delayMicroseconds(25);
}
}

View File

@ -1,4 +1,4 @@
#pragma once
void setupStepper();
void demoStepper();
void demoStepper(bool dir);