debug crap
This commit is contained in:
parent
784f94c569
commit
71051983f2
@ -2,11 +2,15 @@
|
|||||||
#include <Stepper.h>
|
#include <Stepper.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// Defines the number of steps per rotation
|
|
||||||
const int stepsPerRevolution = 2038;
|
|
||||||
|
|
||||||
// TODO: fix rounding errors
|
// TODO: fix rounding errors
|
||||||
int stepsPerDegree = stepsPerRevolution / 360;
|
// int stepsPerDegree = stepsPerRevolution / 360;
|
||||||
|
float stepsPerDegree = 5.688;
|
||||||
|
|
||||||
|
// Defines the number of steps per rotation
|
||||||
|
const int stepsPerRevolution = stepsPerDegree * 360;
|
||||||
|
|
||||||
|
|
||||||
// Creates an instance of stepper class
|
// Creates an instance of stepper class
|
||||||
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
|
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
|
||||||
@ -16,21 +20,39 @@ Stepper stepperY = Stepper(stepsPerRevolution, 4, 5, 6, 7);
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Nothing to do (Stepper Library sets pins as outputs)
|
// Nothing to do (Stepper Library sets pins as outputs)
|
||||||
|
Serial.begin(9600); // Open serial port at 9600 baud rate
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void turnDegrees(Stepper stepper, int deg){
|
||||||
|
stepper.step(deg * stepsPerDegree);
|
||||||
|
}
|
||||||
|
|
||||||
|
void processCommand(String command) {
|
||||||
|
stepperX.setSpeed(10);
|
||||||
|
stepperX.step(command.toInt() * stepsPerDegree);
|
||||||
|
Serial.println(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
// Rotate CCW quickly at 10 RPM
|
// if (Serial.available() > 0) { // Check if data is available
|
||||||
stepperX.setSpeed(10);
|
// String command = Serial.readStringUntil('\n'); // Read input until newline
|
||||||
stepperX.step(-stepsPerRevolution);
|
// command.trim(); // Remove any extra whitespace or newline characters
|
||||||
delay(1000);
|
// processCommand(command); // Process the received command
|
||||||
|
|
||||||
// Rotate CCW quickly at 10 RPM
|
// // Serial.println(command);
|
||||||
stepperY.setSpeed(10);
|
// }
|
||||||
stepperY.step(stepsPerRevolution);
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void turnDegrees(Stepper stepper, int deg){
|
search();
|
||||||
stepper.step(deg * stepsPerDegree);
|
|
||||||
|
// // Rotate CCW quickly at 10 RPM
|
||||||
|
// stepperX.setSpeed(10);
|
||||||
|
// stepperX.step(-stepsPerRevolution);
|
||||||
|
// delay(1000);
|
||||||
|
|
||||||
|
// // Rotate CCW quickly at 10 RPM
|
||||||
|
// stepperY.setSpeed(10);
|
||||||
|
// stepperY.step(stepsPerRevolution);
|
||||||
|
// delay(1000);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user