Arduino Simon Says Tower

by Bread Wielder in Circuits > Arduino

215 Views, 0 Favorites, 0 Comments

Arduino Simon Says Tower

IMG_20220617_165049.jpg

Made by Mike Fens

Introduction

15 June 2022

This is a variation on
the well known game Simon Says (electronic version) for those looking for a challenge. While I over exaggerate a bit with the “challenge” part when it comes down to playing it, it most certainly is a challenge to build following this specific build. There are many part which can be improved on and I would advise you yourself to look into how to do so (the maintainability of this project is non existent).

The goal for this project is to build a working version of Simon Says which can have the buttons and lights change places using a servo. Doing so should make the game a bit harder as simply remembering the location of the buttons is no longer enough. We are also removing the colours from the led lights as this would invalidate the previous change. Lastly we want to make this project small enough to be somewhat portable (you may decide to ignore this part).

Requirements

Required to Build:

- Case base (3 pieces)

110mm in diameter circle (see image 1 below).

- Case inner cross (5 – 10 pieces) (use the left over triangles to form the button tops)

(see image 2 below)

- Case outer circle (35 – 40 pieces) (The outer circle should be 0.5 cm wide.)

110mm in diameter circle.

Within this you cut out another circle of 100mm in diameter.

From this circle you cut out a cross in the middle 10mm wide on each side.

All three of these case parts should be somewhere around 3mm thick.

(see image 2 below)

- Servo (1 piece) (my servo is included in the images below) (including a way to connect the Servo to a mdf board (I used a

screw)).

- White leds (4 pieces)

- Push buttons (4 pieces) (shown in image below)

- 270 Ω ±5% (J) resistor (4 pieces) (Use these for the leds)

- 10 kΩ ±5% (J) resistor (4 pieces) (Use these for the buttons)

- Red wire (9 -10 pieces)

- Black wire (6-7 pieces)

- Yellow wire (5 pieces)

- Arduino (I used a UNO)

- A way to power the arduino (in this project I use a power adaptor)

Tools/ materials: (Not necessarily needed if another solution is found)

- Drill (5,5 mm, 3,5 mm).

- Glue (strong enough to glue something small to a hard flat surface)

- Access to a laser cutter.

- Mdf boards (another material can easily be used, this is just what I used).

- More glue (for the specific material you are using to build the case).

- Solder and all tools required to use it.

Note: the specific amount and sizes of these parts are not set in stone. Most of these parts benefit from being a bit longer as long as you make the case bigger as well. To do so you must simply add a few case outer circles to your project. You may add as many wires as you want that ware as long as the case can handle the wires noted above are the bare minimum assuming you use wires long enough for your case.

Images

Image 1.png
Image 2.png
IMG_20220609_031048.jpg
155-01.jpg.thumb_400x300.jpg

Schematic

Schematic.PNG

The Schematic above shows
how each part should be connected. This Schematic does not show how to build the final version of the project. The final version will be build vertically, this only shows how everything should be connected. It will be up to you how you tackle the specific detail of building this project. Use this schematic now or when working on step 1 to test the whole design for yourself and get an understanding of how it all works.

You can add the following code into your Arduino to make it all work (the comments within the code should explain what each part of it does).

Code

#include <Servo.h>
Servo myservo;

bool gameStart = false;
int level = 1;
int sequence[100];
int currentSequence = 0;

//assigns the right uses to each pin.
void setup() {
pinMode(2, OUTPUT);
pinMode(6, INPUT);
pinMode(3, OUTPUT);
pinMode(7, INPUT);
pinMode(4, OUTPUT);
pinMode(8, INPUT);
pinMode(5, OUTPUT);
pinMode(9, INPUT);
myservo.attach(10);
}

//gain sequence
//creates a random number from 1 - 4 (2-5 (not 6)) and adds it to the array.
//this array shows which buttons the player has to press.
void get_sequence()
{
for (int i = 0; i < level; i++)
{
randomSeed(millis());

if (sequence [i] == 0){
sequence[i] = random(2,6);}

digitalWrite (sequence[i], 1);
delay (200);
digitalWrite (sequence[i], 0);
delay (200);
}
}

//turns on all lights to signify that a mistake has been made by the player.
//after which the game will turn off requiring a button press from the player to start again.
void fault() {
digitalWrite(2, 1);digitalWrite(3, 1);digitalWrite(4, 1);digitalWrite(5, 1);
delay(500);
digitalWrite(2, 0);digitalWrite(3, 0);digitalWrite(4, 0);digitalWrite(5, 0);
delay(500);
gameStart = false;
}

//turns off all leds.
void all_leds_out(){
digitalWrite(2, 0);
digitalWrite(3, 0);
digitalWrite(4, 0);
digitalWrite(5, 0);
}

void loop() {
//Button states
int buttonState6 = digitalRead(6);
int buttonState7 = digitalRead(7);
int buttonState8 = digitalRead(8);
int buttonState9 = digitalRead(9);

all_leds_out();


//current sequence reset
//makes the player start from the beginning of the sequence again after having put in the correct sequence.
//will also add 1 to the sequence length (level) there fore requiring another button press from the player the next time around.
if (currentSequence >= level) {
currentSequence = 0;
level += 1;
randomSeed(millis());
myservo.write(random(0, 90));
delay (500);
get_sequence();
}

//led 2-5 check if the button is pressed and if the button pressed is the correct one compared to the one shown in the array.
//if the button pressed is not the correct one it wil tell the game a misake was made other wise the game wil continue as normal.
//Led 2
if (buttonState6 == 0 && gameStart == true){
if (sequence[currentSequence] == 2){
digitalWrite(2, 1);
currentSequence += 1;
delay (300);
digitalWrite(2, 0);}
else {
fault();
buttonState6 = 1;
}
}

//Led 3
if (buttonState7 == 0 && gameStart == true){
if (sequence[currentSequence] == 3){
digitalWrite(3, 1);
currentSequence += 1;
delay (300);
digitalWrite(3, 0);}
else {
fault();
buttonState7 = 1;
}
}

//Led 4
if (buttonState8 == 0 && gameStart == true){
if (sequence[currentSequence] == 4){
digitalWrite(4, 1);
currentSequence += 1;
delay (300);
digitalWrite(4, 0);}
else {
fault();
buttonState8 = 1;
}
}

//Led 5
if (buttonState9 == 0 && gameStart == true){
if (sequence[currentSequence] == 5){
digitalWrite(5, 1);
currentSequence += 1;
delay (300);
digitalWrite(5, 0);}
else {
fault();
buttonState9 = 1;
}
}

//start game
//resets all variables to their default, then starts the game by asking for a sequence of 1 in length.
if ( gameStart == false && ( buttonState6 == 0 || buttonState7 == 0 ||buttonState8 == 0 ||buttonState9 == 0 )) {
for(int i=0; i<100; i++) {
sequence[i]= 0;
}
currentSequence = 0;
level = 1;
gameStart = true;
get_sequence();
delay (300);
}

}

Step 1: Experiment

IMG_20220601_221125.jpg
IMG_20220307_014701.jpg
IMG_20220509_013725.jpg
IMG_20220529_210955.jpg
IMG_20220530_172453.jpg

To start the project off I did some testing to make sure all my equipment worked. This is also the time for you to test any changes you want to make to the project to make sure it doesn’t set the whole thing on fire or something Bellow this text you will see two pictures of me testing my leds on a bread board and a test version of the same led soldered into a “button top”. The button top has a hole drilled into one end to hold the led. This hole has to be just as big has the middle part of your led to make sure it fits through but doesn’t fall out. If you want to make sure yours doesn’t fall out you can always just glue it together. This will stop you from removing the button top from your project to see the insides and requires it to be soldered last if you do this. This test also ensures you know how to solder your other leds as you need 4 almost identically soldered leds.

(Images include some other tests/ expiriments I have done before starting the project.)

Step 2:making Holes.

To start you want to drill 1 hole into every button top part to put a led into. Drill 1 hole into every ¼ of two of the case base so it has a total of 4 holes. You want to put these holes around the centre of each ¼. Also make sure the holes are spread apart far enough from the centre that the servo fits in the middle and they don’t end up in the place you would like to put your button. The holes should be big enough to fit through a few wires and the wires connecting to your servo. Further in this project we will use these holes to connect the top and bottom part together so make sure you can pull your wires through these small holes.

Step 3: Glue the Case

Take the outer rings of the case and glue them on top of each other so you end up with 3 big stacked parts. One top part in which you want to put your case inner crosses. These should also be glued into it so they form a four way divider. Make sure this part is high enough to fit you buttons in. You want to glue this part on top of the case bases with 4 holes. A middle part which should be high enough to fit the servo. This should be glued on top of the other base with four holes. The last part should be glued on the bottom of this same case base with four holes. It should be high enough to fit y our Arduino plus a little room for the wires. I would recommend you glue all of these parts together bit by bit and not all at once. You can also glue the servo to the middle part so it turns the part above it from the centre. Do this before everything else has been glued! When you have done so you want toput a screw through the middle of the top base and into the servo. This will connect them together and make the whole top container rotate around when the servo is activated.

Step 4: Solder Parts

IMG_20220530_172443.jpg

You now want to solder your buttons and leds while you wait for the case to dry. Use the schematic shown above to see how exactly you have to connect your parts and your previous experiments as examples. WARNING! DO NOT SOLDER THEM TO THE ARDUINO YET! THIS WIL COME LATER.

​ Step 5: Glue the Soldered Parts

IMG_20220616_181849.jpg

You now want to glue your soldered buttons onto the top base.The picture on the right shows how mine has been placed. I soldered the button on a small board and glued that to the base in the middle of the triangle. After it dries you can pull the wires through the hole. In case you have already glued your servo in the middle of the container underneath this one you can also pull all wires through the holes in the base beneath this part. In the end you should have all the button wires go from the top of the case all the way to the bottom where the Arduino is located.

After this you may also pull the Led wires through the same holes as the button wires. Be sure you have the led placed in one of the button tops. The end result will look like the three closed spaces in the picture.

​ Step 6: the Final Solder

IMG_20220616_181938.jpg
IMG_20220616_181959.jpg

I’m not going to lie to you, if you have no experience with soldering this step is going to be hell. The picture below shows what my end result was. It is an absolute mess and probably only readable by me. You should use the schematic to make your own version of this.

In short you want to connect all your wires you have pulled through the holes in the case to the Arduino. How you do this is up to you but I chose to get two separate boards to solder the wires onto. One of these was custom made to fit into my Arduino while the other was a much smaller and loose board just for the servo (which also connected to the Arduino board).

Step 7: Finishing Up

After having connected every last wire to the Arduino and having tested it to make sure the whole project works correctly you can start finishing up the project. Push or pull the some wires a little back into the middle container so they have enough room to move when the servo rotates. Drill a hole into the side of the bottom container with the Arduino through which you can plug your adaptor into your Arduino. If everything works you can glue or tape (if you want to be able to open it again) another base to the bottom of the project to seal the Arduino into the bottom container.

Step 8: Reflect on Your Mistakes

In the end the whole
project worked. This does not mean I had an easy time building this myself though. Having no prior experience with solder I made many mistakes and wasted many wires. For those reading this before starting their project here are some things I would do differently if I were to build this project again.

- Practice with solder a few times on a small scale.

What I mean is try soldering a lot of wires on a very small surface and see if you can not only make it work but also organized. One of my big problems at the end was not being able to see where all my wires went to thus causing confusion when having to redo some of them.

- Make sure you have enough wires in different colours.

While making this project I ran out of orange wires which I used for both the buttons and leds. This left me with two slightly different brown colours as replacements. At first this will not make a big difference. However when you pull all the wires from the top to the bottom you can no longer see which wire belongs to what part. Not only did I have the problem of having to find out which orange belonged to the leds or buttons. I also had to separate the functions of both browns by labelling them. I lost quite a bit of time decoding my own mess.

- Maintainability, Maintainability, Maintainability.

This project has no “maintainability” this means that if something breaks during any step you can go all the way back to step one. I had a lot of issues with this as I made a mistake somewhere in my project and had no way to open up the case to see where I made a mistake. Instead I had to painstakingly check every single wire one by one. For your project I recommend thinking about how you can open the case without breaking everything. I suggest using something like magnets instead of glue for the bases.

As for some positives:

- The end result delivers on what it set out to do.

It is relatively small and a bit more difficult than the original in my opinion.

- Building the case in separate parts makes it really flexible.

Anyone can now make their case as big or small as they like while I had the luxury of making mine two rings taller when I found out that my Arduino needed just a bit more room due to the addition of the wires. If you have access to a laser cutter please use it. For this project I used one of these for the first time and I now know how much of a time saver they can be.

- I now have the feeling I understand the Arduino basics.

Having never worked on any electronic device like an Arduino in this way I had no idea how it worked. Having done this project I now feel like I know enough that I can look at other projects and understand how they work.