I am making a card shuffler wheel that has 52 slots and the wheel is to spin to a random open slot and then have a single card input into that slot. Process repeats until all 52 slots are full and then other stuff happens but Im focusing on the shuffling part first.
I have a code written that turns the wheel to random slots, however, the code isn't designed to not go to any taken slots.
Pls let me know if there is a better way of doing this to have all 52 slots full randomly with no duplicates. PS: wheel can only spin one direction due to physical design.
#include <Stepper.h>
#define motorSteps 3200
#define motorPin1 8
#define motorPin2 9
Stepper stepper(3200, 8,9);
int x;
int Slots[52] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52};
void setup() {
stepper.setSpeed(115);
Serial.begin(9600);
}
void loop() {
static int Times = 0;
if (Times <52) {
x=Slots[random(52)];
stepper.step(-246.15*x);
delay(2500);
Times = Times +1;
}