2024-06-01 02:22:57 +02:00
|
|
|
#include "StepperController.h"
|
|
|
|
#include "StepperXController.h"
|
|
|
|
#include "Time.h"
|
|
|
|
|
|
|
|
#define LeftPin 3
|
|
|
|
#define RightPin 2
|
|
|
|
|
|
|
|
Time time;
|
|
|
|
|
|
|
|
void setup(){
|
|
|
|
// Start serial communication at 115200 baud
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
|
|
|
// Set the pin mode for the defined pins
|
|
|
|
pinMode(LeftPin, INPUT_PULLUP);
|
|
|
|
pinMode(RightPin, INPUT_PULLUP);
|
|
|
|
|
|
|
|
initSteppers();
|
|
|
|
initXStepper();
|
|
|
|
}
|
|
|
|
|
|
|
|
float position = 0;
|
|
|
|
|
|
|
|
void loop(){
|
|
|
|
// Updates deltatime
|
|
|
|
time.update();
|
|
|
|
|
|
|
|
stepperXLoop();
|
|
|
|
|
|
|
|
bool left = digitalRead(LeftPin) == LOW;
|
|
|
|
bool right = digitalRead(RightPin) == LOW;
|
|
|
|
|
|
|
|
processJoystickInput(left, right);
|
|
|
|
|
|
|
|
// //Serial.print(millis());
|
|
|
|
|
|
|
|
// Serial.print("Left state: ");
|
|
|
|
// Serial.print(left);
|
|
|
|
// Serial.print(" | ");
|
|
|
|
// Serial.print("Right state: ");
|
|
|
|
// Serial.println(right);
|
|
|
|
|
|
|
|
if (Serial.available() > 0){
|
2024-06-01 02:31:58 +02:00
|
|
|
beginGrabSequence();
|
2024-06-01 02:22:57 +02:00
|
|
|
Serial.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delay(10); // delay in milliseconds
|
|
|
|
}
|
|
|
|
|
|
|
|
void beginGrabSequence(){
|
2024-06-01 02:31:58 +02:00
|
|
|
moveStepper(StepperAxis::Head, 100000, 75);
|
|
|
|
moveStepper(StepperAxis::Y, 10000, 0);
|
|
|
|
moveStepper(StepperAxis::Head, 1000, 0, 100);
|
|
|
|
moveStepper(StepperAxis::Y, 10000, 1000);
|
2024-06-01 02:22:57 +02:00
|
|
|
}
|