Arduino Simon

Last year I decided to build a simple Simon style game using an Arduino. The game has four LEDs, each a different color, and a corresponding button for each LED. The game lights up a pattern of LEDs, one after another, and the player repeats the pattern to progress to the next level. Each level builds upon the previous level by adding one more element to the sequence. There is also a simple buzzer that provides audio feedback. Each LED is assigned a pitch that is played when it lights up, and there’s a victory “song” that is all of two notes!

Hardware

The LEDs were connected to digital pins on the Arduino via 220 ohm resistors. The buttons, or momentary switches, were connected to digital pins using 10k pull down resistors. The buzzer was connected directly to a digital pin. Turns out the buzzer was really loud, so I made a covering out of clay to reduce the volume. I originally used an Arduino Uno, but later decided I wanted something more compact, so I changed to the Nano. I also started with tiny DIP push buttons, but they were difficult to use, so I swapped them out for bigger push buttons.
simon-arduino-circuit-diagram

Parts List

The Code

The tone function was used to play notes on the buzzer. To create a random sequence for the player, I used the random function, and set the seed with an analogRead from pin zero, which was floating. The rest was just digitalWrite (to set the LED states), digitalRead (to check the button presses), delays, and keeping track of game state in memory.

Photos

v1 – With tiny buttons and Arduino Uno
simon-arduino-v1

v2 – With bigger buttons and Arduino Nano
simon-arduino-v2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s