Total Recall- Arduino Simon Says on steroids

Total Recall Game

Total Recall is a Simon based game for the Arduino. Your basic Arduino Simon Game consists of 4 buttons, 4 LEDs, an Arduino, some code and maybe a speaker and sound effects. Total Recall takes things a step further by adding an LCD display and offering  1 and 2 player game modes.

The 1 Player game is your basic Simon Game. I added 4 levels of difficulty to it by giving you options for how many rounds you want to play. Your then given a sequence of flashing lights to mimic. Each round adding an extra flash to the sequence. If you can complete the number of turns you win.

The 2 Player game puts you head to head against a friend. The game starts with player one entering the first button into the sequence. The Sequence is then played back for player 2 to see. Then player 2 gets to mimic the sequence. If he gets it correct he gets the opportunity to add a button to the sequence. Then Player 1 gets the play back and tries to mimic the sequence. The game goes back and forth like this with the sequence getting increasingly longer till one player gets it wrong or you reach 99 turns in which case you’ve hit the max length of the sequence and the game is a draw.Total Recall Game

Materials Needed:

  • Arduino (I used a Nove)
  • Bread Board
  • Jumper Wires/Ribbon cables
  • Red, Yellow, Green and Blue LEDs
  • 4x 100 Ohm Resistors
  • 4x Push Buttons
  • Small Speaker
  • Hitachi HD44780 based 16×2 LCD
  • 5K Potentiometer

Step 1: Background

After posting Arduino Simon Says i started getting ideas for ways to improve the game. Whenever possible i like to simplify my code to reduce the amount of memory it uses. One of the things that really eats up memory in an Arduino sketch is using the Serial interface. Since the eventual goal is to get this game onto its own PCB and make it an actual portable game linking it to a computer to track your progress wasn’t going to be an option. Removing the Serial commands from the game dropped 2004 bytes from the compiled code. So to help me towards my goal of portability i decided to add an LCD display to the game.

Then i started thinking how i could make the game play even better. And what better way to make a game more fun then to play it with a friend. So i would need to come up with a menu system allowing you to choose between the 2 game types. I also wanted to make the original Simon game more interesting as well. So i decided it would be good to give people the option of how many turns they could shoot for. Nothing like giving people a goal to shoot for to make things more interesting.

Now a checklist of ideas was starting to come together.

  1. Add LCD display
  2. Create difficulty options for single player game
  3. create 2 player game

All these ideas raised many questions.

Step 2: Adding the LCD

Before i did anything i wanted to clean up the mess of wires a bit on the project. So i created three ribbon cables about 12 inch long from an old 40 wire IDE cable. I split the cable into 3 six wire strips and soldered header pins to each end. On one end of each i clipped the headers down to individual pins and split the wires about 2 or 3 inches up. The joined ends sit neatly into the Arduino while the split ends give me the freedom to reach any components i need. When all connected only Digital I/O pins 0 and 1 are left with nothing connected. I’ve been meaning to this this for quite some time.Total Recall Game circuit

Now i was ready to figure out where to connect my LCD. Considering most of my Digital I/O pins where taken i had to figure out where i was going to connect the LCD. I wanted to keep as many of the LCD wires as close together as possible. This makes it a bit easier to troubleshoot any problem. I also didn’t want to move the LEDs and Buttons around. This would just add to the headach of updating the code. So i decided to place the LCD on the Analog In pins. The Analog Pins can be used as Digital I/O pins. The are designated as follows: 

  • Analog 0 = Digital 14
  • Analog 1 = Digital 15
  • Analog 2 = Digital 16
  • Analog 3 = Digital 17
  • Analog 4 = Digital 18
  • Analog 5 = Digital 19

I couldn’t put all the LCD pins across the Analog pot cause i still need Analog pin 0 for randomization of the single player game. So the LCD is connected as follows:

  • RS pin to D13
  • E pin to D12
  • D4 pin to D16
  • D5 pin to D17
  • D6 pin to D18
  • D7 pin to D19
  • V0 tied to a pot to control brightness
  • Grd and R/W tied to ground
  • Vcc to +5V

You can refer back to the Arduino Simon Says Instructable concerning the setup of the rest of the hardware. The only change made was moving the speaker over to pin 6. I hope the Fritzing image helps to clear up any confusion there might be in the wiring. I went ahead and attached the Fritzing file if you need a better look at the diagram. You can also refer back to my Custom Large Font For 16×2 LCDs for more information about setting up a Hitachi HD44780 based 16×2 LCD on the Arduino.

Step 3: Menu Coding

I spent a good 6 to 8 hours just trying to work out a menu system. I wanted the opening screen to show the name of the game. It then needed to tell you to select a game and show you the game options. When the 1 Player Game is selected it wil then go to another menu where you can choose the difficulty level.

Many ideas where tried and failed. Ultimately this is what i came up with. below is just a snippet of the code showing you how the menu works.

void Menu() //menu display
{
lcd.clear();
lcd.print(” Sellect number”);
lcd.setCursor(3,1);
lcd.print(“of players”);
delay(1500);
}

void loop()
{ //menu system for selecting 1 or 2 player game
if (game == 0) //no game selected
{
lcd.clear();

for(int y=0; y<4; y++)
{
lcd.setCursor(0,0);
lcd.print(“1 Player: RED”);
lcd.setCursor(0,1);
lcd.print(“2 Player: YELLOW”);

buttonstate = digitalRead(button[y]);

if (buttonstate == LOW && button[y] == 2)
{
button1(); //calls for the RED button’s LED to light and tone to play
game = 1; //1 player game
}

if (buttonstate == LOW && button[y] == 3)
{
button2(); //calls for the Yellow button’s LED to light and tone to play
game = 2; //2 player game
}
}
}

if (game == 1 && turnlimit > 1) //as long as 1 turn has been taken in the 1 player game
{
play1(); //calls to the 1 player game
}

if (game ==1 && turnlimit < 1)  //no turns have been taken in the 1 player game
{
play1menu(); //calls to the menu to select number of turns for 1 player game
}

if (game == 2)
{
play2(); //calls to 2 player game
}
}

void play1menu() //menu for selecting 1 player difficulty
{
lcd.clear();
lcd.print(“Red=10 Yellow=20”);
lcd.setCursor(0,1);
lcd.print(“Green=30 Blue=40”);
delay(100);

for(int y=0; y<4; y++)
{
buttonstate = digitalRead(button[y]);
if (buttonstate == LOW && button[y] == 2)
{
button1();  ////calls for the RED button’s LED to light and tone to play
turnlimit = 10; //sets number of turns
}

if (buttonstate == LOW && button[y] == 3)
{
button2();
turnlimit = 20;
}

if (buttonstate == LOW && button[y] == 4)
{
button3();
turnlimit = 30;
}

if (buttonstate == LOW && button[y] == 5)
{
button4();
turnlimit = 40;
}
}
}

The void Menu() is the start of the menu system. The game’s Name display happens in the void setup(). When the setup is complete it calls directly to void Menu() then starts in on the void loop(). In the void loop() i used several variables to keep track of the state of the code. Like which game is being played. So that everything else can be bypassed and the current game can continue. If the single player game is selected it jumps down to void play1menu() where your given the difficulty option. The difficulty is set by the number of turns you want to play and stored as turnlimit.

Read more: Total Recall- Arduino Simon Says on steroids

Leave a Comment

Your email address will not be published. Required fields are marked *