# How to make simplest Arduino European Roulette Game ( 37 Leds )

Roulette is a casino game named after the French word meaning little wheel which was likely developed from the Italian game Biribi. In the game, a player may choose to place a bet on a single number, various groupings of numbers, the color red or black, whether the number is odd or even, or if the numbers are high (19–36) or low (1–18). To determine the winning number, a croupier spins a wheel in one direction, then spins a ball in the opposite direction around a tilted circular track running around the outer edge of the wheel.

There are two popular roulette wheels: American and European. The European wheel has only one zero while the American wheel has two zeroes. Also the number sequence is different.
This time I will present you how to make an electronic version European  roulette, where the movement of the ball is simulated by successive lighting of LEDs.

Note that you can see the original project at "www.theohupkens.nl/English/RouletteWheel.html" and I have only slightly modified the code by adding another level of spin duration. In one of my previous videos (https://www.youtube.com/watch?v=H_85lFRJ9T8&t=7s) I also presented Arduino Roulette, but it was much more complicated and difficult to make.

This time is used the Charlieplexing technique, also known as tristate multiplexing, reduced pin-count LED multiplexing, complementary LED drive and crossplexing. This is a technique for driving a multiplexed display in which relatively few I/O pins on a microcontroller are used to drive an big array of LEDs.
Thanks to this technique, the 74HC595 shift registers are omitted this time and the device is incredibly simple to build. It contains only a few components:
- Arduino Nano microcontroller
- 37 Leds
- five resistors
- Button,
- and Speaker

A few words about the way of connecting the diodes. The first diode is connected directly to the D11 pin and ground through a suitable resistor. The remaining 36 diodes are divided into 4 groups of 9 diodes. The cathodes of each group through a resistor are connected to A1 to A4 analog pins. The anodes of each group are connected sequentially (for example: Led2, Led11, Led20, Led29 together and connected to D2 pin of Arduino) and those 9 terminals are connected to D2 to D10 pins of the Arduino.
If you want to make a PCB for this project, or for any other electronic project, PCBway is a great choice for you. PCBway is one of the most experienced PCB manufacturing company in China in field of PCB prototype and fabrication. They have a large online community where you can find a Open Source projects, and you can also share your project there. From my personal experience I can tell you that on this community you can find many useful projects.

Now let's see how the device works in reality:
After startup four leds will rotate for a short period of time. After starting, four LEDs will rotate for a short period of time, after which one diode will remain lit. To turn the ball (LED) we have to press the button and the moment we release it the game starts. There are three levels that regulate the duration of the ball spin. If the button is pressed for less than 0.5 seconds, the rotation speed is the lowest, from 0.5 to 5 seconds the rotation speed is normal, and finally if we keep the button pressed for more than 5 seconds, it will take a minute and more to stop the ball.
During the whole time while the ball is moving, a characteristic sound is emitted through the speaker.
In the following, you can see the way in which the device is made
Finally, the entire device is installed in a suitable box made of PVC board with a thickness of 3 mm and covered with self-adhesive colored wallpaper

CODE
``````// Roulette, European Wheel
// c(2017) Th.M. Hupkens. Tested with an Arduino nano

#define PushButton 12

#define Click A5
#define ZeroLed 11
int quarter = A1; // Keeps track of in which quarter the current led is
int led; // Keeps track of which led is ON
bool CCW = true; // Counter clockwise
void setup() {
for (int i = 2; i <= 11; i++) pinMode(i, OUTPUT);
pinMode(PushButton, INPUT_PULLUP);
for (int a = A1; a <= A5; a++) pinMode(a, OUTPUT); // LOW = ON
for (int nowmber = 1; nowmber < 4; nowmber++)
for (int i = 2; i <= 10; i++) { // Animation when wheel starts up
digitalWrite(i, HIGH);
delay(200 - nowmber * 40 - (i - 2) * 5);
digitalWrite(i, LOW);
}
randomSeed(analogRead(A0)); // Initialise the random nowmber generator
led = random(2, 11); quarter = random(A1, A5); // choose led from 1 to 10; choose quarter from A1 to A4
for (int a = A1; a <= A4; a++) digitalWrite(a, a != quarter); digitalWrite(led, HIGH);
}

void loop() {
unsigned long now = millis();
unsigned long tijd = millis() - now;
int Steps = 37 + random(18); // For the time being
if (tijd > 500) Steps *= 2;  // Pressing the push button more than half a second gives a longer roll
if (tijd > 5000) Steps *= 2.01;
int Stap = 1;
while (Stap < Steps) {
Stap++;
digitalWrite(led, LOW);
if (CCW) {
led++;
if (led > 10) {
if (quarter == A4) {
if (led > 11) {
quarter = A1;
led = 2;
}
}
else {
led = 2;
quarter++;
}
}
}
else { // if NOT counter clockwise
led--;
if (led < 2) {
if (quarter == A1) {
led = ZeroLed;
quarter = A4;
}
else {
led = 10;
quarter--;
}
}
}
for (int a = A1; a <= A4; a++) digitalWrite(a, a != quarter); // if a is not the current quarter then a -> HIGH else a -> LOW
digitalWrite(led, HIGH);
digitalWrite(Click, HIGH); delayMicroseconds(40); digitalWrite(Click, LOW);
unsigned int delaytijd = 40 + Stap * 5;
if (tijd > 500) delaytijd /= 2;
delay(delaytijd);
}
CCW = !CCW;
}``````