ClawMachineCosplay/ClawMachineOverhaul.ino

57 lines
1.1 KiB
C++

#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();
moveStepper(StepperAxis::Y, 10000, 1000);
}
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){
Serial.flush();
}
delay(10); // delay in milliseconds
}
void beginGrabSequence(){
moveStepper(StepperAxis::Y, 10000, -1000);
moveStepper(StepperAxis::Y, 10000, -1000);
}