As a child I enjoyed playing an electronic light-and-sound game called Simon. This memory had completely slipped my recollection until I recently saw something about it on the internet.
As this seemed to be a good subject for some Arduino recreational programming, I did some research and recreated the game using Arduino code. Here’s the result.
Simon is an electronic game of memory skill. The original version was manufactured and distributed by Milton Bradley, launched in 1978. It was an immediate success and remained popular throughout the 1980s.
The device is a circular disk with 4 colored ‘lenses’ that can light up and produce a particular tone when pressed by players or activated by the device.
A round of play is the device lighting up one or more buttons in a random sequence, after which players reproduce the order by pressing the colors in the same sequence until they make a mistake and the game ends.
An interesting fact is that original game’s tones were designed to always be harmonic no matter the sequence. Musically it is an A major triad in second inversion (resembling a trumpet fanfare) with the following notes:
- Blue: E
- Yellow: C♯
- Red: A
- Green: E (an octave lower than blue)
Rules of the game(s)
The original Simon actually had three styles of game that could be played solo or with multiple players.
Game 1 – Correctly repeat an ever longer color sequence
Simon shows the first color. The player repeats this color by pressing the color button. Simon then duplicates the first color and adds a second. The player repeats both colors. The game continues with Simon adding one color and the player repeating the whole sequence.
After the sequence reaches a length of 5, 9 and 13 colors, the game speeds up. The game ends what the player makes a mistake, takes longer than 5 seconds to repeat a color or the longest allowed sequence is repeated correctly.
Game 2 – Create longer and longer sequence of colors
Simon provides the first color. The player repeats the color and adds a second color to the sequence. The same or another player then repeats the first 2 colors and adds a third color to the sequence. The game continues with each next player repeating and adding one color to the sequence.
The game ends when a player incorrectly repeats the sequence, takes longer than five seconds for their move or the longest allowed sequence is repeated correctly.
Game 3 – Correctly repeat single colors faster and faster
Each player chooses one color as theirs. Each time Simon flashes a color the player owning that color has to repeat it. The game gets faster and faster as it progresses, as the time allowed for each turn decreases slightly after each color.
The game ends when a color is pressed out of sequence or a player takes longer than the allowed time to repeat the color.
Simon Arduino style
The full sketch for this project can be found at my code repository.
The minimal hardware required for this game – four active low switches, four colored leds and a piezo buzzer – was easily assembled from existing components using my prototyping boards, described in this past post, and shown below.
To keep it simple, each I/O element is connected to its own Arduino pin, defined in the sketch.
The original game had a few more switches to select the different game modes, but this version just uses the existing color switches for the same purpose. The well proven MD_UISwitch library is used to debounce and manage the switches.
The standard Arduino tone library is used to drive the piezo buzzer. The notes used for each colored LED, defined in the standard pitches.h header file, are the same as described above.
The game is implemented as four finite state machines – one per game type and one more (in loop()) to select and manage the play mode. Each FSM is relatively straightforward as it simply implements play according to the rules defined above.
Once the software has played a short opening tune, the player needs to select the type of game to play. One of the LEDs will be blinking to indicate the current play mode (green (default) for game 1, yellow for game 2, blue for game 3). The player changes the mode by selecting a different color and that LED will start blinking. The game starts when a blinking LED is selected. Once that game ends Simon returns to the last mode selection (blinking LED), waiting for the next game choice.
As per the rules of the game, a game cycle ends either:
- when a player’s move times out (ie, takes too long for the next press). Simon gives a long beep on the color that was supposed to be pressed and quits the game.
- when the maximum sequence length is reached (the MAX_CODE_LENGTH constant). Simon double cycles all the LEDs and then quits the game.
Most of the game functions are not concurrent or time critical, so code blocking delay() calls are not a problem and are used extensively through the code. The exception is when user input and timeout monitoring needs to occur at the same time – a non-blocking time check is used to keep the system responsive.
It was nice to get this ‘memory lane’ project done over a couple of afternoons. Even after all this time, I still enjoyed playing this version of the game and I can see it would still appeal to kids of all ages today. Hopefully this version of the classic game will bring the same fun for others.