Simon Project
Project Summary
Although mechanical engineering is largely based around the interaction of physical components, I believe that the ability to program, even at a basic level, is a valuable asset for any engineer to have given the prevalence of software in nearly every field or discipline of engineering. As such, I set out a coding challenge for myself in which I attempted to re-create the memory game Simon using an Arduino Uno. Although this project never came to true fruition in that I did not have the time to create a fully working product, this experience was valuable for me to learn and strengthen my knowledge about good coding practices, logic, and electronics/circuits. In order to make this as thorough a learning and problem-solving experience as possible, I swore off Google for this project unless as a final resort. Although it is not fully functional yet, I intend to analyse and troubleshoot my system until it operates as I have designed it to.
A picture of my wiring
The Hardware
The process of building the circuit was rather simple. It contained two main components: an input module and an output module. The input module involved an array of four pushbuttons that were meant to be the interface through which the user plays the game. Each button fed into a different digital input terminal on the Arduino. The output module involved four LEDs of different colours and a piezo buzzer. The buzzer would play short melodies to signal the start of a game, button presses, and the end of games, either a win or a loss.
The Code
This part of the project was considerably more difficult than the hardware portion. To make things simpler, I broke the project up into three sections:
Introduction
Gameplay
Endgame (Victory/Defeat)
The introduction and endgame phases involve playing a pre-set melody through the piezo buzzer. By setting certain parameters in the code, the program was able to determine whether it should play the victory or defeat theme when it reached the endgame stage. I encountered problems coding the 2nd stage of the project, the gameplay itself. I was able to get the Arduino to produce a random sequence of lights and tones, but I am still working on user input and having the program store the user's input and compare it to the program-generated tone sequence.
The Arduino code I used for my project