ClawMachineCosplay/ClawMachineOverhaul.ino

60 lines
1.2 KiB
C++

#include "StepperController.h"
#include "StepperXController.h"
#include "Time.h"
#define LeftPin 3
#define RightPin 2
#define grabPin 19
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);
pinMode(grabPin, 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);
if (digitalRead(grabPin) == LOW){
beginGrabSequence();
}
// //Serial.print(millis());
// Serial.print("Left state: ");
// Serial.print(left);
// Serial.print(" | ");
// Serial.print("Right state: ");
// Serial.println(right);
delay(10); // delay in milliseconds
}
void beginGrabSequence(){
moveStepper(StepperAxis::Head, 1000, 100);
moveStepper(StepperAxis::Y, 10000, -1100);
moveStepper(StepperAxis::Head, 1000, -100, 100);
moveStepper(StepperAxis::Y, 10000, 1100);
}