Simon Says Write up - Najiblalani/Simon GitHub Wiki


Najib Lalani
Guy Cortesi
ICEN 150
May 6th, 2018
Simon Says Final Project Write Up

The project was to recreate the classic game of Simon says using the Arduino. The game works based on levels, on the first level one of four lights blinks and the player must press the correct button that blinks. Depending on what level your on that’s how many lights blink in a random order. So, if you’re on level five, 5 lights will blink and then the user must press the buttons in the right order that were played. Building a circuit with LED’s and buttons and writing code using the Arduino the game can be made.

The project I built doesn’t completely function like the full game as I ran into issues that are discussed in the next paragraph. The circuit is made with 3 LED’s and 3 buttons with 6 resistors and a buzzer as seen in the schematics and Tinkercad images. For the resistors there are 3 10k ohm resistors for the buttons and 3 330 ohm resistors for the LED’s. I have two functions in my code. The first function plays 5 random LED’s while the second reads if buttons are being pressed and lights up the corresponding LED along with its specific sound. The two functions can be seen in the code section labeled as playerInput and randomLights.

While attempting to complete the final project I ran into a few issues. My problems first stemmed from my unfamiliarity with the Arduino sketch language that is C. Specifically I struggled with writing functions and getting them to work like comparing the user input to make sure they pressed the correct buttons in the same order that was played from the LED’s. I attempted this by trying to use a nested for loop. The other issue I ran into was with sketch’s main method which is called void loop. It was hard for me to deal with this because functions I would only want to run once would run forever. I tried to work around this by calling functions in other functions but eventually if I called a function in the void loop it would still run forever.

Although I couldn’t get the game fully functioning I think I learned a lot about working with sketch. The circuit was correct as to how the game is setup my issues were with improving my code to make the game work properly. I could have implemented a standby to deal with the infinite loop that sketch uses. The various tools used for the project had different strengths. Tinkercad is very helpful as a simulation tool and makes fixing mistakes much easier before actually building the circuit. Unfortunately, a schematic can’t be made using Tinkercad so that’s where Fritzing can be utilized as it can be used to build a circuit just the Tinkercad that then converts into a schematic and gives a parts list as well. GitHub is also very useful as it is a common place to store everything about a project so that the public can work on it together. In conclusion I believed I learned a lot from this project even though I had difficulty in completing it.

Tinkercad Diagram

Fritzing Schematic

Fritzing Assembly List

Fritzing Shopping List

Player Input Function

Random Lights Function

Random Led Explained
This code snip-it is how LED’s are randomly chosen to blink, it first randomly generates a number that is 0,1,2 and stores it in an array. Then the random lights function above is called and reads the array at each index and what ever value is it reads it then the corresponding LED blinks. For example if the value in position 3 of the array is 0 then the blue led will blink. Every time the program is ran the array will be different.

⚠️ **GitHub.com Fallback** ⚠️