Roulette Wheel

Most Arduino devices have about twenty output pins, so to control the 37 leds of an electronic roulette wheel, without extra electronics seems impossible. However, with a simple trick we need only 16 output pins including a pin for the buzzer, and one input pin for the press button. The trick is explained at the bottom of this page.

About roulette

After startup four leds will rotate for a short period of time..
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. I made a European one. The wheel itself should turn alternatively clockwise and counter clockwise, and the ball is thrown in the opposite drection. To keep the project simple I decided not to add any moving parts, but the "ball" rotates clockwise and counter clockwise as it should. The croupier (or dealer) is not allowed to throw the ball too slowly. For this reason in this electronic roulette wheel the ball will rotate always at least one full round. If you push the button for more then half a second, the ball will run faster. Of course you can change this behavior as you like. This is just a working example of what is possible.
In principle at the start of a session, the ball is released near the number of the day of the week. From then on the ball will be released near the numer where it just landed. However, the Arduino does not keep a calender so this cannot be implemented without extra electronics. Instead, we will release the first ball at a random position.

Construction

Proceed as follows: print a photograph of a roulette wheel on glossy paper and cut out the circular shape. The size should be at least about the width of an A4 paper.
Cut a circular disk of the same size from hardboard, mdf or plywood. Paint the border and around the edge of this disk with the same color as the border of the printed roullette wheel. This way small imperfections will become invisible. Use a picker to make two small holes in each slot, where a led should come. The distance between the holes should be about 2,5 mm. You can use a piece of veroboard as a template. Drill the hole with a 1 mm drill. Also drill a larger hole in the middle of the disk where the push button fits in. Insert all leds the same way in the holes. Push the leds tight against the disk and bend the long legs towards the center of the disk, and the short legs towards the border of the disk.
Bottom of the wheel
Be careful when fastening the push buton because the printed photograph is easily damaged. Now you must wire the leds. Start with the led that is in slot number 0; we will call this "L0". Solder a resistor on its short leg. It depends on the type of led you have which resistors you need. I use resistors of 330 Ω. If you don't know the specs of your leds, you can try on a breadboard which resistor is needed. If lowering the resistor value decreases the brighness when the led is on then you must use a higher value. Also if the led is much too bright you should lower the value of the resistor. L0 must be connected to pin D11 of the Arduino and (via the resistor) to one of the GND pins, but wait until the other connections are ready. Divide the leds in four rows of 9 neighboring leds. Say, in clockwise direction we have group 1 to group 4. Now use a wire to solder together the short legs of all leds within a group. Silver plated copper wire of about 0,6 mm diameter will do fine. Solder a resistor at the end of each wire. Now connect all long legs from group 1 to the correcponding led from group 2 and from group 3 and 4. So: if you number the leds from L1 to L36 (starting with the led next to the 0 led) you have to connect L1 to L10 and to L19 and to L28, also L2 must be connected to L11, L20 and L29, and so on. Next connect L1+L10+L19+L27 to D2 and L2+L11+L20+L28 to D3 of the Arduino, and so on. The free side of the resistors of each group, go to the pins A1 through A4 of the Arduino. There is no principal reason to use anolog pins, but in this case it is convenient. One leg of the push button must be connected to GND, the other to D12. Connect a buzzer or loudspeaker to GND and A5. Caps of bottles, that you would otherwise throw away, can be used as legs. Usually you will glue them upside down to the bottom of the wheel, but if the caps are flat, you can do it the way I did.
ON/OFF button in a leg
If you use three equally spaced, identical legs, the wheel will guaranteed be stable. I have concealed the ON/OFF switch in one of the legs (see image). The positive pole of the battery goes to the switch, the other side of the switch goes to the VRAW or VIN pin of the Arduino; the negative pole goes directly to GND. Attach the battery to the board, for instance using velcro (see photograph).

Trick

The trick is rather simple. If we would have connected the four short legs of the leds with GND, all leds would light up together. However, the short legs are connected to A1, or A2, or A3, or A4. If any of these pins are at 5 volt instead of zero, then the corresponding leds will not light up, because the voltage across the leds will be zero. Hence, we will put all A-pins HIGH except for the led that must be on. At the start of the program, we leave all A-pins zero. We then increase the number of the led that is on. So you will see four rotating leds during a short period of time. Then the wheel is ready to be used. When developing an Arduino program (sketch) you will have to keep track of the group to which the led belongs. That's easy, because after every 9 leds we start with the following group of 9 leds. A small complication is that L0 only appears after the last group or before the first. But as you can see in the fully functional example program below, it is still relatively simple.
This trick will work if you turn one or more leds from the same group on OR if you turn corresponding leds from several groups on. But take care: if you turn many leds from the same a group ON, the resistor might become hot due to the larger current. The trick can NOT be used when two or more arbitrary leds must be on at the same time.
Click to see or hide the sketch

Note this trick can be implemented in several different ways, for instance one could change the polarity of the leds and change HIGH and LOW in the sketch accordingly.

Rien ne va plus!