- Environmental monitoring with uChipPosted 5 days ago
- ARDULEGO KIT: create with Lego and ArduinoPosted 3 weeks ago
- Share & Discover by PCBWayPosted 4 weeks ago
- ENERGY METER IOTPosted 1 month ago
- Energy Meter GSM with Arduino (part 2)Posted 2 months ago
- Energy Meter GSM with Arduino (part 1)Posted 2 months ago
- ARDULOCK: a keyboard with RFID modulePosted 2 months ago
- Autofocus Glasses/Phoropter Using Variable Focus Liquid LensPosted 4 months ago
- Home Automation & Lights controlling SystemPosted 4 months ago
- Solar TrackerPosted 5 months ago
An Electronic LED Roulette you can self build
Let’s call back an electronic version of one of the most famous casino games: no tricks and no cheats…
The “roulette” is without a doubt one of the most famous and practiced casino games in the word, and it is surely one of the most widely employed, along with poker, in famous movies from all genres: from Westerns to police movies, from spy stories to comedy. Among the various versions available in the world, known as French roulette, English roulette and American roulette, we took inspiration from the first one, which is definitely the most famous; the main difference amongst various versions mainly focuses on the presence of the double “0” or lack thereof and on the disposition of black and white numbers.
Obviously, we couldn’t but present an electronic interpretation of our roulette, therefore we thought about how to design a circuit capable of reproducing the rotating movement of the ball thanks to the sequential lightning of a set number of LEDs. In the solution we designed and that we are going to describe in the following paragraphs, the ball’s circular movement can be obtained by piloting 37 colored LEDs in an appropriate manner and the final number can be outputted through unilateral lighting of one of those LEDs.
The electronic part of our roulette is divided in two boards: control unit and LED panel.
In order to simplify but also making the realization of this project much more interesting, we took advantage of our dear old digital logics TTL/CMOS, however, in order to keep up with the times, we will use their modern versions which are HCMOS (74HCxxx). For a more in-depth approach to digital logics it would be very useful to read the theoretical introductions to articles presented on issues 170/171 (digital capacitance meter) and 182 (oroLED project), where we analyzed in depth both logic families and individual components used in those two projects, some of which are also used here. For this reason, we can also include this new project in our “vintage” line, since the whole component range goes back to the 70s and 80s of last century.
We are going to start by describing the control unit, let’s begin by saying the most difficult part of this project was being able to generate, through hardware only, a piloting clock for the counters that would start from a set frequency and then progressively decrease until reaching 0; this was used to correctly emulate the real roulette wheel’s behavior which starts off quickly and then spins slower and slower until it comes to a halt. In order to solve this problem, we took advantage of a particular configurator and the always-reliable NE555 (U1) integrated circuit. An astable multivibrator used as a clock generator for logic ports has been used as a base setup, and the components R1-R2-C3 set the starting frequency; the formula used to calculate the generated frequency in our case is:
F = 1,443/[C3 (R1 + 2R2)] =
1,443/[100 * 10-9(220000+200000)] = 1,443/(0,0000001*420000) = 1,443/0,042 = 34,37 Hz
Unlike the classic astable configuration, R1 is not directly connected to the +5V, since we placed a button in-between which is normally open, and its purpose is to start or stop the counting.
If we press and hold P1-button (which is placed at the center of the LED panel and its contacts go on the logic circuit through CN1’s 5-pin and 6-pin, responding to CN4’s 5-pin and 6-pin) on the output of NE555 we are going to actually have a fixed frequency equal to around 34 Hz (real value depends of course on tolerances of the three composed used); at the same time, C1 capacitor is charged through R3 (which purpose is basically to prevent the shock following the short short-circuit created every time we press the button when the capacitor is empty). Once we release the button, C1 capacitor starts to discharge through R4, and this causes a gradual decrease of voltage on R1 and, as a consequence, a decrease of output frequency from NE555’s 3-pin, passing from initial 34 Hz to 0 Hz. It is therefore clear that if we want to increase or decrease starting frequency we have to modify the values of R1-R2-C3, while if we want to either increase or decrease the “ball’s spinning time” we’re going to have to increase or decrease the value of C1 capacitor or possibly even the value of the discharge resistor R4.
On NE555’s 3-pin we take this variable clock and we are going to directly apply it to 14-pin of U2 (74HC4017), which is a x10 counter/divider; in fact, with each clock cycle applied to 14-pin only one of the Q0-Q29 outputs, sequentially, goes to HIGH level. Lines from Q0 to Q6 provide positive power and as many –LED groups (1-pin to 7-pin of CN2 connector, which corresponds to CN3 connector of the LED panel), while lines from Q7 to Q9 are powering three groups of 3 LEDs each through 8-pin to 10-pin of CN2. This Integrated circuit, therefore, only plays the role of unit counter, once it activates Q9 it starts over from Q0 but at the same time it sends a clock impulse (through its 12-pin) to 14-pin of the second U3 counter (another 74HC4017), which activates a sequence (similarly to what we just saw for the unit counter) in its Q0÷Q3 outputs, in order to manage ten-counting. Each one of these outputs is buffered by one of the BC547 transistors labelled T1÷T4, in order not to overload the counter although, in actuality, the 20 mA current that the two outputs of the integrated circuits can provide should be enough to drive the high luminosity LEDs we have employed. Notice that, although we have used transistors in their typical common emitter configuration, we added just one common limiting resistance (R5), instead of using four individual ones for each collectors as one would normally expect. The reason why we have used this “trick” is that only one LED will be on each time, among the 37 that we have on the panel, this way we can save to some precious space on the logic board, without damaging the LED piloting. The four transistors’ collectors are therefore positively powering the four LED rows (three 10-LED rows and one 7-LED row).
In short, functioning is the following: let’s suppose, for instance, that at the beginning both Q0 outputs are active: first LED lighting up will be the green LED (number 0, green), because it’s the only one receiving a positive voltage on the anode and the negative voltage on the cathode; at the following clock impulse U1’s Q1 output will be activated, while U2 stays on Q0, lighting the red LED (number 32, red); the following clock cycle will activate U1’s Q2 output, while U2 stays on Q0, therefore now the blue LD10-LED will light up (number 6. Blue), and so on until activation of Q6 output of U1 and Q3 output of U2 that will turn on the blue LD36-LED (number 26, black). Since there is no following LED, the system will reset itself starting from the green LD0-LED, then the next clock cycle will activate outputs Q7 of U1 and Q3 of U2; in this singular situation, NAND port “D” of U4 (a 74HC00) will have both inputs and HIGH logic level, on its output we will find a LOW logic level that will be inverted and brought to HIGH by the NAND port “C” of U4, which is used in inverter configuration (that is with the two input pins connected together); in order to better understand this mechanisms, we once again invite you to read the articles we referenced at the beginning of this article. The HIGH signal simultaneously applied to RESET pins of U1 and U2 will instantaneously lead to activation of both Q0 outputs, and the cycle will start over when LD0 lights up. Basically, we realize a simple but effective matrix with 37 LEDs, by assigning each one of them a color corresponding to the original French roulette; we used a green LED for the zero, red LEDs for the same color and blue LEDs for black, but if you’re going to use a mask with the classic representation of striped-band colors, you can easily use the same color LEDs, we think the most appropriate would be white or blue, in order not to play tricks on the dealer’s eyes!
Randomness is absolutely guaranteed because, although frequency range is basically fixed, running time of the “ball” will change each time, that is the following lighting up of the 37 LEDs with highly depend on pressure time on P1 button but also owned existing operational conditions of C1 capacitor, and we know that temperature differential and functioning time will also influence its charge and discharge times.
Finally, as we can clearly see from the diagram, we decided to bring the clock outside, through the OUT BF output, and send it to a small audio amplifier; we used a small 2846-PAM8403POT module that you can purchase on www.futurashop.it and that was featured and issue 198 (2x3W amplifier), with stereo inputs and outputs, a power of 3+3 watts on 4 ohms, 5V supply and volume potentiometer with on-off switch; once connected to a small loudspeaker, the result is exceptional, because you can replicate the noise of the ball spinning inside the plate, the noise gets slower and slower, perfectly synchronized with the LEDs’ movement, because we actually used the same clock.
You can use any other audio amp system, provided it malfunctioning or even freezing the entire circuit.
The circuit absorbs around 70 – 80 mA so it can be powered either with a 5V wall adapter or a battery pack with compatible characteristics; in this case you will of course have to rethink the packaging solution we proposed.
The electronic part for the roulette is placed on two printed circuits, one containing power supply logics and input (logic board), while the other one is the display panel, a round panel to honor tradition; this one contains the LEDs and the button to launch the “ball”.
In order to finish assembly, the two female header connectors must be welded together, perfectly perpendicular to the PCB.
Picture shows the mounted logic board. Notice that, in our case, power connector is mounted on the welding side; the reason for this is that JST connectors often have an open female plug and their red and black wires do not have a standardized polarity; therefore the socket must be welded in such a way to match red wire with the positive +5 V input, indicated on the serigraphy with n°1, and the black one with ground. You can then go on and mount the LED panel, and you must pay close attention to colors here, and follow our instructions to the letter, otherwise you will have problems interpreting the outputted number for each corresponding LED lighting up; you also have to pay attention to LED polarity, and follow the indications on the serigraphy. The criterion to follow is very simple: the first LED (LD0) is the only green one, each odd-numbered LED on the serigraphy (LD1, 3, 5 etc.) are red, while each even-numbered LED on the serigraphy (LD2, 4, 6 etc.) are blue; moreover, red and blue LEDs are always alternating, there will never be two LEDs of the same color next to each other. In our prototype, LEDs are completely embedded in the PCB and directly in contact with its surface; if you prefer to mount them higher you of course have to create a space because the “ball” effect needs them to be on the same height.
The LED panel can be mounted with two male strip connectors, which must be of adequate length taking into account that P1 button will be placed on the central section; connectors used in the prototype in the picture are 3 cm long. P1 button will be inserted in a lower portion of the panel and is fixed with a nut on the bottom, therefore it has to be connected to the two specific emplacements with two wires that you are going to weld.
Once the electronic and mechanical part is mounted we can finally move on to test phase. All you have to do is connect a 5Vcc power adapter (watch out for polarity!) And press and hold P1 button; if everything goes well, you will see LEDs lighting up sequentially and clockwise with a speed of around one full circle per second. Once the button is released, the LEDs will continue “rotating” for around eight or nine full circles with decreasing speed until they stop completely, on a randomly selected LED.
A good way to make sure the outcome is absolutely random is holding down the button for a number of seconds that varies every time: this way the cycle effect was start upon release and from a non-identifiable point due to maximum rotational speed.
If one or more LEDs do not light up during rotation you have to verify if both pins for each LEDs are welded or if they are inverted. If an entire 10-LED section or 7-Led section doesn’t light up (LD0 to LD29 or LD30 to LD36), or a group of four interspersed LEDs, you have to check the welding of strips and headers (CN1÷CN4) and the correct functioning of related transistor or the piloting integrated circuit (U2 or U3). Finally, it might happen that there is no rotational or the rotation behaves abnormally; in this case the problem with almost certainly be in the NE555; if you have connected in amplifier to related BF output you will have to disconnect it and verify that everything works. If this is the case it means that the amplifiers input has a low impedance and the oscillator becomes overloaded, or it has a malfunctioning which determines an excessive load and decreases the clock.
If rotational frequency is too high or too low you must verify the values of R1, R2 and C3, while if rotational time is too low or too high you have to act by respectively increasing or decreasing value of C1 capacitor or R4 resistance.