34 lines
749 B
C
34 lines
749 B
C
#include <ContinuousStepper.h>
|
|
#include <ContinuousStepper/Tickers/Tone.hpp>
|
|
|
|
ContinuousStepper<StepperDriver, ToneTicker> stepper;
|
|
|
|
void initXStepper(){
|
|
stepper.begin(/*step=*/54, /*dir=*/55);
|
|
stepper.setAcceleration(10000000);
|
|
pinMode(38, OUTPUT);
|
|
}
|
|
|
|
void stepperXLoop(){
|
|
stepper.loop();
|
|
}
|
|
|
|
bool isMovingLeft = false;
|
|
void processJoystickInput(bool left, bool right){
|
|
if (left){
|
|
// if (!isMovingLeft){
|
|
// isMovingLeft = true;
|
|
// stepper.stop();
|
|
// }
|
|
stepper.spin(16000);
|
|
}
|
|
else if (right){
|
|
// if (isMovingLeft){
|
|
// isMovingLeft = false;
|
|
// stepper.stop();
|
|
// }
|
|
stepper.spin(-16000);
|
|
}
|
|
else
|
|
stepper.stop();
|
|
} |