Loading...
Loading...
// Stepper Turntable Controller
#include <AccelStepper.h>
AccelStepper stepper(AccelStepper::DRIVER, 3, 4);
const int HOME_SENSOR = 2;
const int STEPS_PER_TRACK = 200; // Adjust for your turntable
int currentTrack = 0;
void setup() {
stepper.setMaxSpeed(500);
stepper.setAcceleration(100);
pinMode(HOME_SENSOR, INPUT_PULLUP);
homeTable();
}
void homeTable() {
while (digitalRead(HOME_SENSOR) == HIGH) {
stepper.move(1);
stepper.run();
}
stepper.setCurrentPosition(0);
currentTrack = 0;
}
void goToTrack(int track) {
int steps = (track - currentTrack) * STEPS_PER_TRACK;
stepper.move(steps);
while (stepper.run());
currentTrack = track;
}This is starter code - modify and expand for your specific needs.
Before building this project, make sure you have the Arduino IDE installed and are comfortable uploading basic sketches to your board.
Most projects use standard Arduino libraries. Some may require additional libraries like AccelStepper, Servo, or NmraDcc - install these through the Arduino Library Manager.