Mirko Pavleski
Published © GPL3+

DIY 37 LED Roulette Game

Following the principle of the original Roulette, the movement of the LED simulates a ball whose speed gradually decreases until it stops.

IntermediateFull instructions provided7,528
DIY 37 LED Roulette Game

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
74HC595 shift register IC
×5
LED (generic)
LED (generic)
×37
Buzzer
Buzzer
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Pushbutton Switch, Momentary
Pushbutton Switch, Momentary
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

Code

C/C++
 int SER_Pin = 8;   //pin 14 on the 75HC595
int RCLK_Pin = 9;  //pin 12 on the 75HC595
int SRCLK_Pin = 10; //pin 11 on the 75HC595
int buttonPin;
//How many of the shift registers - change this
#define number_of_74hc595s 5

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

int Randomwaarde;
int del = 5 ;
void setup(){
 pinMode(SER_Pin, OUTPUT);
 pinMode(RCLK_Pin, OUTPUT);
 pinMode(SRCLK_Pin, OUTPUT);
  buttonPin = 7; //whatever pin your button is plugged into
  pinMode(buttonPin, INPUT_PULLUP);
 //reset all register pins
 clearRegisters();
 writeRegisters();

 randomSeed(analogRead(3));
 Randomwaarde = random(190, 210);
 Serial.println(Randomwaarde);
}              

//set all register pins to LOW
void clearRegisters(){
 for(int i = numOfRegisterPins - 1; i >=  0; i--){
   registers[i] = LOW;
 }
}

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

 digitalWrite(RCLK_Pin, LOW);

 for(int i = numOfRegisterPins - 1; i >=  0; i--){
   digitalWrite(SRCLK_Pin, LOW);

   int val = registers[i];

   digitalWrite(SER_Pin, val);
   digitalWrite(SRCLK_Pin, HIGH);

 }
 digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
 registers[index] = value;
}

void loop(){
 //check button pressed, if so enter program condition (inside if statement)
  if(digitalRead(buttonPin) == LOW) //functions based off of button pulling input pin LOW
  {
 for (int x=0; x<=36; x++)
 {
   if (del <= Randomwaarde)
   {
     setRegisterPin(x, HIGH);
     writeRegisters();
     delay(del);
     setRegisterPin(x, LOW);
     writeRegisters();
     del = del +1;
   }
  delay(10000);
  }
 }
}

Credits

Mirko Pavleski

Mirko Pavleski

117 projects • 1165 followers

Comments