AnnemariArduino
![AnnemariArduino || ITTT](/proxy/?url=https://content.instructables.com/FKC/BAUF/LHW02WOW/FKCBAUFLHW02WOW.jpg&filename=AnnemariArduino || ITTT)
![20230517_180729.jpg](/proxy/?url=https://content.instructables.com/FQC/EC96/LHRPRC8W/FQCEC96LHRPRC8W.jpg&filename=20230517_180729.jpg)
When I started this project I struggled a lot with coming up with a concept. The only thing I was sure of was that I wanted to make a game. Eventually, I got the tip to just mess around with the components I already had and to do some research to discover what types of components are out there. My first idea was to build a self-watering plant pot, but you always need to look further than your first idea. So I looked further and I came up with the idea I went for: AnnemariArduino (Annemaria koek koek/Red light, green light).
The concept of the game is really simple. When the red light is on, you don't move. When the green light is on, you move. To win the game you need to be close enough to push the button. When you do move when the light is red, you will hear a buzzer sound which means it's game over for you.
I wanted to make this game because, when you play this without the Arduino, you always need to be with more than 2 people. Kids who, for example, struggle to make friends or are only childs can now play this game by themselves without needing another person!
Supplies
Components:
- Arduino Uno
- Breadboard
- PIR motion sensor
- 1x Red LED
- 1x Green LED
- 3x resistors
- Button
- Jumper wires male-male
- Jumper wires male-female
Components for soldering:
- Soldering iron
- Tin
Components for the case:
- Lego
- Sturdy white paper
- Green paper
- Red paper
- Black paper
- Washi tapes with fun patterns
Connecting the Components to the Arduino
![AnnemariArduinoCircuit.png](/proxy/?url=https://content.instructables.com/FZD/JJL3/LHUKO34G/FZDJJL3LHUKO34G.png&filename=AnnemariArduinoCircuit.png)
![20230507_135105.jpg](/proxy/?url=https://content.instructables.com/F62/2O0P/LHT597GP/F622O0PLHT597GP.jpg&filename=20230507_135105.jpg)
For the first step, you'll need your components as listed in the supplies. With these components, you're going to build the circuit as shown in the picture.
When you've built this we are going to put some jumper wires male-female to our two LED lights and the button. We need to do this because this way they are lifted off the breadboard. We're going to need this when we are going to put everything in our case.
I also want you to know that there are two orange knobs on the PIR motion sensor. One is for changing the sensitivity and the other one is for changing the time delay. It took me quite a while to figure these out because my sensor is different than the ones I saw on the internet, as it is mirrored. I eventually figured it out, now it's time to figure yours out! On some PIR motion sensors it's written above the orange circles, mine didn't have that, unfortunately.
The Code
You'll find the code to make everything work right here! Copy and paste the code or download the INO file down below.
int preperationTime = 4; // starting time in seconds
int ledG = 13; // the pin that the green LED is attached to
int ledR = 12; // the pin that the red LED is attached to
int sensor = 4; // the pin that the PIR sensor is attached to
int buzzerPin = 8; // the pin that the buzzer is attached to
int buttonPin = 3; // the pin that the button is attached to
int pirState = LOW; // by default, there's no motion detected
int val = 0; // variable to store the sensor status (value)
bool green = false; // variable to store status of the green LED
int buttonState = 0; // variable to store the status of the button
bool playingGame = false; // variable that keeps track of if the game is playing
void setup() {
pinMode(ledG, OUTPUT); // initalize green LED as an output
pinMode(ledR, OUTPUT); // initalize red LED as an output
pinMode(sensor, INPUT); // initialize sensor as an input
pinMode(buttonPin, INPUT); // initialize button as an input
Serial.begin(9600); // initialize serial
RestartGame(); // for starting or restarting the game
}
void loop(){
green = false;
LightUpdate();
float randomNr = random(1500, 3000); // variable that stores random amount of milliseconds
RedLight(randomNr);
green = true;
LightUpdate();
randomNr = random(1000, 2000);
for(int i = 0; i < randomNr; i++){ // makes the finish button play a sound when pushed
buttonState = digitalRead(buttonPin);
if (buttonState == 1) {
tone(buzzerPin, 200, 300);
delay(150);
tone(buzzerPin, 300, 300);
buttonState = 0;
RestartGame();
}
delay(1);
}
Serial.println(buttonState); // keeps track of the state of the button to check if it's really doing it's job
delay(1);
}
void LightUpdate(){ // function that changes the led lights corresponding to the state of the green variable
if (green){
analogWrite(ledG, 255);
analogWrite(ledR, 0);
}
else {
analogWrite(ledR, 255);
analogWrite(ledG, 0);
}
}
void RedLight(float _randomNr){
for(int i = 0; i < 500; i++){
buttonState = digitalRead(buttonPin);
if (buttonState == 1) {
tone(buzzerPin, 200, 300);
delay(150);
tone(buzzerPin, 300, 300);
buttonState = 0;
RestartGame();
}
Serial.println(buttonState);
delay(1);
}
for(int i = 0; i < _randomNr; i++){
if (buttonState == 1) {
tone(buzzerPin, 200, 300);
delay(150);
tone(buzzerPin, 300, 300);
buttonState = 0;
RestartGame();
}
val = digitalRead(sensor); // Makes the buzzer play a losing sound when sensoring movement, only when the red LED is on
if (val == HIGH) {
if (pirState == LOW) {
tone(buzzerPin, 200, 300);
delay(150);
tone(buzzerPin, 150, 300);
delay(150);
tone(buzzerPin, 100, 300);
delay(150);
tone(buzzerPin, 50, 500);
Serial.println("Motion detected!");
pirState = HIGH;
playingGame = false;
delay(4000);
RestartGame(); //Restarts game when motion is detected
}
}
delay(1);
}
}
void RestartGame(){ //Restarts game with 5-10 seconds preperation time, give or take
delay(750);
Serial.print("get ready ");
for(int i = 0; i < preperationTime; i++){
Serial.print(".");
delay(1000);
tone(buzzerPin, 100, 200);
}
delay(1000);
tone(buzzerPin, 200, 600);
playingGame = true;
pirState = LOW;
}
Downloads
Soldering
![20230509_011455.jpg](/proxy/?url=https://content.instructables.com/FW8/RJVN/LHT597GS/FW8RJVNLHT597GS.jpg&filename=20230509_011455.jpg)
Let's get soldering! I know this sounds scary, but luckily we won't have to do much of it.
I chose to not solder my wires to a different board. It works perfectly fine on my breadboard, I've had no issues with it. The things that I did solder were the wires to my push button and the wires to both of my led lights. I chose to solder these because they kept coming apart, when I soldered them the issue was of course gone.
To solder your wires to your push button and your led lights you'll need a few things:
- Soldering iron
- Tin roll
- Pincers
First, we need to free the copper wires from the plastic that's covering it. To do this you lightly need to cut the plastic loose from the copper. It takes some practice, but once you get the hang of it it's totally do-able. When you've freed the copper, we're going to wrap the copper around the part of the component that we want to solder to the wire. Then you're going to let your soldering iron heat up. When it's ready, you're going to grab the tin in one hand and the soldering iron in the other. Touch the soldering iron to the tin so that it will melt and the copper and the part of the component are stuck together. In the picture, you'll see how I soldered mine. You will repeat this step for the buzzer, the green led light, and the red led light.
When they are all stuck together sturdy, you're done with soldering!
Building the Case
![20230518_233952.jpg](/proxy/?url=https://content.instructables.com/FW4/Z01P/LHT597IY/FW4Z01PLHT597IY.jpg&filename=20230518_233952.jpg)
![20230518_233945.jpg](/proxy/?url=https://content.instructables.com/FZN/AEGL/LHT597IX/FZNAEGLLHT597IX.jpg&filename=20230518_233945.jpg)
![20230518_234009.jpg](/proxy/?url=https://content.instructables.com/FDK/IBI3/LHT597IZ/FDKIBI3LHT597IZ.jpg&filename=20230518_234009.jpg)
![20230518_233508.jpg](/proxy/?url=https://content.instructables.com/FCJ/CA9Q/LHT597IU/FCJCA9QLHT597IU.jpg&filename=20230518_233508.jpg)
![20230518_233458.jpg](/proxy/?url=https://content.instructables.com/FHN/MXX4/LHT597IT/FHNMXX4LHT597IT.jpg&filename=20230518_233458.jpg)
![20230518_233350.jpg](/proxy/?url=https://content.instructables.com/F0Z/E0FZ/LHT597IS/F0ZE0FZLHT597IS.jpg&filename=20230518_233350.jpg)
![20230518_232952.jpg](/proxy/?url=https://content.instructables.com/FPH/JEJ2/LHT597IQ/FPHJEJ2LHT597IQ.jpg&filename=20230518_232952.jpg)
![20230518_232842.jpg](/proxy/?url=https://content.instructables.com/FVT/OZGB/LHT597HY/FVTOZGBLHT597HY.jpg&filename=20230518_232842.jpg)
![20230518_232247.jpg](/proxy/?url=https://content.instructables.com/FIY/ANQD/LHT597H0/FIYANQDLHT597H0.jpg&filename=20230518_232247.jpg)
![20230518_232231.jpg](/proxy/?url=https://content.instructables.com/FKL/TCKX/LHT597GZ/FKLTCKXLHT597GZ.jpg&filename=20230518_232231.jpg)
![20230518_232516.jpg](/proxy/?url=https://content.instructables.com/F6V/YIMM/LHT597H1/F6VYIMMLHT597H1.jpg&filename=20230518_232516.jpg)
![20230518_232052.jpg](/proxy/?url=https://content.instructables.com/F17/12RA/LHT597GX/F1712RALHT597GX.jpg&filename=20230518_232052.jpg)
![20230518_231650.jpg](/proxy/?url=https://content.instructables.com/FHN/QP2A/LHT597GW/FHNQP2ALHT597GW.jpg&filename=20230518_231650.jpg)
![20230518_231619.jpg](/proxy/?url=https://content.instructables.com/F8Z/SKP0/LHT597GV/F8ZSKP0LHT597GV.jpg&filename=20230518_231619.jpg)
![20230518_231611.jpg](/proxy/?url=https://content.instructables.com/FHN/18OZ/LHT597GU/FHN18OZLHT597GU.jpg&filename=20230518_231611.jpg)
![20230518_231558.jpg](/proxy/?url=https://content.instructables.com/FKD/2BEB/LHT597GT/FKD2BEBLHT597GT.jpg&filename=20230518_231558.jpg)
![20230508_205813 (1).jpg](/proxy/?url=https://content.instructables.com/FU6/UJH1/LHT59GLM/FU6UJH1LHT59GLM.jpg&filename=20230508_205813 (1).jpg)
Let's start with building our case. Im going to use Lego, because it's easy to create sturdy structures with. What kind and color of Lego you use doesn't matter because later we're going to cover it anyway. As long as you can build boxes with it, it's perfect.
First, we're going to build snugly around our Arduino. This is going to be our base. Make sure it can't move around too much. Make this wall you've built around higher. Don't forget to leave a gap for the USB port of the Arduino, this will be the backside. Also, remember to put some flat Legos under the base like a floor. This will prevent the Arduino from falling out of the case. When you're happy with the height of the base, close it off but leave a hole for all the wires + breadboard in the center.
Then were going to build the neck. To build the neck just build a cube-like structure around the hole for the wires. Build this as high as you like. When you've reached the desired height, we're going to build a platform that we'll use as the floor for the head of our case. I gave my head approximately the same measurements as my base, that way my breadboard will fit in the head which is necessary. When building this platform you'll still need to keep the gap for the wires + breadboard. When your platform is done, we're going to build one row of Lego higher on the edge of the platform. At the front (The opposite side of where your Arduino input is) were going to make a gap for our motion sensor and our buzzer. As you can see in the pictures, I made a little bridge over my motion sensor and buzzer to keep them in place. I recommend building this kind of bridge over them because it's really steady. On the same row but higher, we're going to put our green led light. Above our green led light, well put our red led light. I've put these through some special Lego bricks that already have little holes in them. If you don't have those, creating a small hole the size of one Lego block will also work.
When those are ready build the walls all around your platform higher, till you've reached a couple of blocks higher than your red led light. With these higher walls, your breadboard can stay secure in the head. On the row a couple of blocks higher than the red led light, were going to put our push button.
Build the rows a little higher. When you're happy with the height of the walls, you're going to close it all off. When it's all closed off, we're going to make a little border around the edge (As shown in the last picture). Were going to make this because people can hold on to this edge when they push the button. Otherwise, our creation will just fall over when they push the button with a little too much force.
When you've done all these steps you're left with a sturdy case. If it's not as pretty as you'd like it to be, don't worry! We're going to hide all the lego in the next step.
Covering the Lego With Paper
![20230517_181729.jpg](/proxy/?url=https://content.instructables.com/FPK/OTRI/LHRPRDJZ/FPKOTRILHRPRDJZ.jpg&filename=20230517_181729.jpg)
![20230508_223448.jpg](/proxy/?url=https://content.instructables.com/FFT/1HUU/LHS1LSCS/FFT1HUULHS1LSCS.jpg&filename=20230508_223448.jpg)
![20230508_230541.jpg](/proxy/?url=https://content.instructables.com/FGM/5RUR/LHS1LSCR/FGM5RURLHS1LSCR.jpg&filename=20230508_230541.jpg)
![20230518_223012.jpg](/proxy/?url=https://content.instructables.com/FLP/BW9G/LHT59067/FLPBW9GLHT59067.jpg&filename=20230518_223012.jpg)
Now we're going to cover our case with paper. If we wouldn't cover our Lego with paper, it would not look as good as possible (especially in my case). The paper will make it look cleaner. To cover the Lego we will make sort of "sleeves" that will fit perfectly. To make these we will need sturdy white paper, a ruler, a pencil and scissors or a knife.
We will begin with making the sleeve for the base, the place where the Arduino is. We're going to measure the base with a ruler. This is different for everyone so I can not give you the exact numbers, you will have to measure it yourself. When we have the numbers we need we are going to make the sleeve as shown in the picture. That's the shape it needs to be. The big rectangles you see on every side of the sleeve will have the exact measurements as the sides of the base. We will need the extra pieces of paper you see (in the picture) on the sides of the big rectangles to glue them to themselves. The measurements of these little pieces don't really matter, as long as it's big enough to glue on. This is useful because you won't have to glue the paper to your Lego. The extra pieces of paper you see towards the middle of the sleeve (Towards the hole) are so that the top of the base, where the neck is connected, is also covered. We will also need to make a hole in the middle of our sleeve so that we can wrap it around the base and the neck, the hole needs to have the measurements of the neck. When you have all these measurements drawn out on the white paper, it's time to cut it out. Make sure to also make a diagonal cut (You can see mine slighty in the picture), this is necessary because this way you can fold it around the base. Without the cut it's just a square with a hole in it which you can't wrap around.
We are going to repeat these steps but with different measurements and different shapes (depending on your measurements). For the neck it's most likely going to be one long strip made out of rectangles that have the right measurements. The extra pieces at the top and bottom are again necessary, this way we can really hide the lego. These extra pieces will go under the sleeves of the base and the head. So the sleeve of the neck is the first one you'll put on. It also needs one extra piece of paper on the left or right side (your preference), that way you can glue it to itself when you wrap it around the neck.
Last but not least we are going to make the sleeve for the head. You will do the same thing we did for the last two sleeves. Measure every flat side of the head and put that on paper. If you do that correctly it will look something like mine (mine has a little rip in it as you can tell from the picture, this is because I forgot to take a picture and needed to get it off the Lego when I had already glued it in place :( ). This sleeve will have a lot of "extra" pieces of paper on the top sides, that's because of the edge we made higher. So you'll also need to measure every side of the elevated edge and add that to the top side of your sleeve (You can also see it in my picture for reference). On the other hand, the horizontal sides will have less paper than the measurements you got. This is also because of the higher edge. The center of the extra pieces of paper on the top side need to fold over the edge, the sides need to cover the top of the edge. Don't forget to make little holes in the sleeve for the two LED lights and the button, and a bigger hole for the PIR motion sensor. When you're done with this, you're done with all the sleeves we need!
Now we move on to the fun part.
Decorate Your Creation
![20230517_181738.jpg](/proxy/?url=https://content.instructables.com/F0A/Q611/LHRPRDJO/F0AQ611LHRPRDJO.jpg&filename=20230517_181738.jpg)
![20230517_180737.jpg](/proxy/?url=https://content.instructables.com/FLZ/8XH4/LHRPREIS/FLZ8XH4LHRPREIS.jpg&filename=20230517_180737.jpg)
![20230517_180743.jpg](/proxy/?url=https://content.instructables.com/F1C/3EHP/LHRPREI5/F1C3EHPLHRPREI5.jpg&filename=20230517_180743.jpg)
![20230517_180749.jpg](/proxy/?url=https://content.instructables.com/F2J/OG75/LHRPREHT/F2JOG75LHRPREHT.jpg&filename=20230517_180749.jpg)
It's time for the fun part: Decorating! You can decorate it however you like. I, personally, wanted mine to look childish and playful. If you want yours to look the same as mine, this is how I did it. we will need some colored paper (Red/pink, green, and black), washi tape with a fun pattern, a black fine liner, and glue.
First, we will need to cut a rectangle out of both the red/pink and green paper. These will go over the red and green led lights. For that to fit, we need to cut a hole in the rectangles for the led lights to go through. When that fits, we're going to use the black paper. From this paper were going to cut off 12 strips in total for the two rectangles and for the space around the push button. 6 for the horizontal edges, and 6 for the vertical edges. Glue these strips to the edges like I did in the picture. This will create an outline.
When all the paper pieces are glued in place, were going to use some washi tape to decorate it all around. Stick little pieces around your creation wherever you like. When you're done and you're happy with the placements, grab your black fine liner. We will use the fine liner to outline the pieces of washi tape to give it a cartoonish effect.
Lastly, we're going to use that fine liner to make little drawings on every side. I, for example, made a tree, a stickman, and a sun. I also wrote "Koek koek" on the side with some letters facing the wrong way to give it a playful effect. I also wrote "Finish", "Stop" and "Go"
And there you have it, you're game is done and decorated with fun!
I have learned a lot from this project. From programming with an Arduino, to soldering, to facing struggles like the button not working correctly or the motion sensor not working how I wanted it to work. I'm happy that I got this project from school because now I know more useful skills. I had zero experience with an Arduino and not a lot of experience with programming, but I didn't let that stop me and I'm proud of what I made! :)