Skip to content

This was a final project for my microarchitecture and programming class in 2018.

Notifications You must be signed in to change notification settings

KekeliVA/arduino_7segment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Kekeli Afantchao Game Control ECT 242 - Plumley

Introduction: The purpose of this exercise was to design code to drive a gaming machine controller. This gaming machine was to emulate that of a 3 digit mechanical slot machine. It starts the process via button activation. When the button is released three random numbers are displayed on the multi digit display. A slight delay should be employed between the subsequent displaying of other numbers. When the three digits are the same or meet another wildcard condition the three digits should flash simultaneously.

Project Summary/Approach: The variables needed to operate this controller were related to the button, digit assignment, number display, mask, and winning number comparison. The data direction registers required for operation were DDRB (8-13) and DDRB (0-7). Only pins 8-11 were outputs in DDRB and all pins were used in DDRD except for pin 0. Due to the fact that the button is on a pin within DDRB it would send a signal back to the pin and potentially make the arduino think that the button was pressed again. After the mask is used, the result is acted on by an OR with the desired output to PORTD. One of the most pivotal parts of the program being functional depends on the state of the button. To start the main loop a digitalRead is performed on the button which triggers the controlled sequence. This sequence sets the LEDs on the border of the display to a high. On release of the button the three numbers are displayed on the first three digits. This is done by assigning three different variables for each digit random values from the random function. The use of a mask was necessary for each writing to the LED outputs.. After the variables have a value, they are evaluated by a group of if statements for their respective digit and if the condition is met, the corresponding statement block is executed. The functions created for this program included randomize, writetoSegs, and winner. Randomize assigns values to the aforementioned variables that correspond to the appropriate digits. writetoSegs is responsible for the output to the LEDs and winner evaluates the random values to determine if they met the winning condition.

Conclusion: My slot machine is functional, but falls short in some categories. The button was successful in activating the controlled sequence and displaying a number. Something I noticed while writing the code was that I could have made it more compact and efficient. In another revision I attempted to only call functions in the main loop and utilize an array to rid my program of superfluous code. With arrays a large group of if statements would not be necessary because the LEDs could be written straight from the array element. Another aspect of the code that I had trouble with was implementing a delay before the displaying of each number. When a delay was implemented, it caused segments to display in unpredictable ways and the button lost its functionality as well. Lastly, the brightness varies in the display at times. Upon the pressing of the button digit 4, segments b and c shine much brighter than the rest of the LEDs.

About

This was a final project for my microarchitecture and programming class in 2018.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published