Digital 1 Final Project Sequential Digital System - Slot Machine Joseph Messner Thomas Soistmann Alexander Dillman I. Introduction The purpose of this lab is to create a circuit that would represent the digital side of a slot machine. The slot machine would need many different parts in order to represent the all of the different lights one would see on an ordinary slot machine. The first step was to write code to upload to the Arduino Uno. Within the code, a random number generator would pick random numbers between a given range for each of the three slot machine displays. Once all three numbers match, the player has won and a row of red LED s, representing a slot machines general arrangement of lights, will sequentially light up, starting from the center LED and moving to the out most LEDs. When the player has not won, the lights blink simultaneously on an interval. To represent what the player sees while playing a slot machine, a method of representing the randomly spinning pictures on a slot machine was needed. The obvious choice was RGB LEDs, since these lights could cycle through various different colors, which would act as the slot machines display pictures. Once implemented correctly, the RGBs would randomly cycle through different colors one at a time, and would land on a color based off of the randomly generated number in the code written for the Arduino. Now, the colors on the RGBs effectively provide a visual aid for a slot machine player to see if they have won or not. II. Specifications In order to correctly implement the digital side of a slot machine, various different parts, inputs, and outputs were included. The first step was writing the proper code in the Arduino s computer software. This code was key in controlling the red LED light array and the RGB LED counter. The code was then uploaded to the Arduino Uno board, and the signals specified in this code were outputted to the breadboard. A pin on the breadboard also outputs the reset function to the Arduino, so that when the game is over after either a win or a loss, the entire circuit would automatically reset. Furthermore, the Arduino outputs the randomly generated numbers to the RGBs to control which colors are displayed when the game is played. Once all of the generated numbers match, the Arduino outputs a signal that triggers the LED light array. The light array sequentially lights up each LED s, starting from the center and fanning out symmetrically. To further add to the lighting effects of a slot machine, other functionality was added to pulse the LED light array in between the RGB counter cycling.
III. Design Discussion To implement the specified design, a device is needed that could cycle through the different colors that were available on the RGB LEDs. During the initial design process, it was determined that a D-Flip- Flop was needed, since it has the ability to store a bit of data every clock cycle. This can hold and output the value of 1 or 0 every cycle. In the case of LEDs, a Flip-Flop keeps the LED powered as long as a 1 is stored. For RGB LEDs, a three bit number is needed to produce the eight possible combinations. The combinations include Red, Green, Yellow, Blue, Purple, Teal, White, and Black or Off. With this in mind, three D-Flip-Flops are needed to power the three RGB LEDs. Knowing that the Flip- Flops store data every cycle, a method was needed to accurately run through the series of colors. The most effective method to do so, was to implement a ripple counter. A ripple counter would take the output from the previous Flip-Flop, and use it as the clock for the next Flip-Flop. This accurately multiplies the combinations of the circuit to the power of two. After this multiplication was completed, three D-Flip-Flops were provided eight total clock cycles to effectively display each of the combinations. However, a slot machine is not complete with only one reel, so three RGBs were used to represent the three reels on any typical slot machine. Therefore, a total of nine D- Flip-Flops (three per RGB) were needed to complete this portion of the circuit. Originally, this was the implemented design; however, due to errors in circuitry, one or more Flip-Flops did not cycle ideally. As a result of this error, other methods were experimented with, and eventually the ability to use a counter to combine the functionality of all the Flip-Flops was discovered (Figure 1). Each counter took the place of three Flip-Flops, resulting in a total of three counters (one per RGB) required to finally complete this portion of the circuit (Figure 2). Figure 1: Counters for the RGB LEDs. Figure 2: Two RGB LEDs wired to their corresponding counters. In order to control the cycling of the three counters and RGBs, code was written in the Arduino software that could perform the defined task. A random number generator was implemented in the code that chooses three random numbers (one per LED) between a specified range (Figure 3). After a random number was chosen, the counter would count down from this number to 0 (Figure 4). The difference between the chosen number and 0 directly correlates to the number of times the RGB will cycle. Pin 2 on the Arduino outputs to the first counter, Pin 3 outputs to the second counter and Pin 4 outputs to the third counter. If all three of these numbers are equal, another portion of code specifies another pin to produce a signal that controls the LED array (Figure
5). Pin 12 on the Arduino powers the LED light array in its sequential winning circuit for exactly 15 seconds, until the board is eventually reset by Pin 5. However, if the randomly generated numbers are not equal to each other, Pin 5 is high three seconds after the game is finished, and then the circuit is reset. Figure 3: Arduino code that specifies a range of counter cycles. Figure 4: Arduino code representing the comparison of randomly generated numbers. indicator LED (Figure 7). Another counter is in charge of creating the output signals that power the LED array (Figure 8). The three outputs used in the counter are wired to three inputs on a decoder. This decoder further splits the signals and creates the logic that makes the sequential array possible (Figure 9). Since this specific decoder has inverted outputs, a NOT gate integrated circuit was used to reverse the signal to the desired value (Figure 10). Next, comes the LED array itself, which only utilizes five of the outputs on the decoder to power the nine total LEDs. The second output from the decoder, after it is inverted, is wired to the middle LED, and the third output from the decoder is wired to the two LEDs adjacent to the left and right respectively. Finally, the fourth and fifth outputs are wired to the left and right of the previous LEDs on each side of the center LED respectively. Each LED was then connect to ground through a 1k resistors. However, the outputs from the decoder were not wired directly to the LEDs, instead they traveled through diodes to block any signal coming from another source (Figure 11). Figure 5: LED light array powered by Pin 12 of the Arduino and the secondary timer. The logic behind the sequential LED light array begins with a timer. A signal travels into the input pin of the timer via Pin 12 of the Arduino. The timer has various components that alter the speed of its output signal. In order to have a varying output pulse, a potentiometer was implemented into the circuit. A potentiometer is essentially a resistor that can vary its resistance based on the amount degrees rotated from its origin. The output pulse from this timer triggers the next branch in the circuitry along with an Figure 7: Timer with potentiometer and indicator LED outputting a signal to the counter
Figure 8: Counter receiving a clock signal from the primary timer in order to create a count signal for the decoder. Figure 9: Decoder which receives three input signals from the counter and outputs the proper signals to power the LED array. Figure 11: Diodes that stop the flow of current back towards other parts of the circuit. To add more functionality to the slot machine circuit, a blink function was added. Another timer was wired with a set pulse that turns all the LEDs on and off at one time (Figure 12). This acts as a standby function waiting for Pin 12 to output a signal. The output pin of the timer is connect to an indicator LED along with the LED array via diodes, thus stopping all unwanted signal from the sequential portion of the circuit, effectively isolating the LEDSs. When Pin 12 outputs a signal, it travels to the primary timer, like previously stated, and is put through a NOR gate, preventing the secondary pulse function from occurring while the sequential circuit is powered (Figure 13). Figure 10: NOT gate chip which inverts the signal coming from the decoder to properly cycle the LED light array. Figure 12: Secondary timer chip that controls the pulsing in between cycles of the RGB LEDs.
V. Appendix Figure 13: NOR gate which stops the secondary timer from cycling when Pin 12 on the Arduino is powered. IV. Conclusion Figure 14: Arduino Uno board used for random code generator and comparator to control the logic in this circuit. While the final product was successful, the only thing that had proved to be an issue was the original design which implemented the plethora of D-Flip-Flops. Besides for this hiccup, all other functionality of the circuit properly works. The RGBs cycle between all color combinations to represent the rapidly spinning visuals on a slot machine. The LED array fans out from the middle symmetrically like planned, and they also pulse in between victories to add to the various different lighting effects one would see when they sit down to play. While the circuit built in this lab does not represent an entire slot machine, it serves its purpose in representing the fundamental and most noticeable parts of the machine. When creating this project the work was split fairly equal. Joe Messner physically built the circuit and coded the Arduino while Tom Soistmann and Alex Dillman helped design. Tom created many of the used specifications, and wrote a significant portion of the lab report with Joe providing insight into some of the final circuits functionality. Alex put in his fair share of time coming up with ideas and writing the lab report as well.