This is a great intermediate level Arduino project for those just starting out! After doing a handful of tutorials, I came up with this project to tie together several of the basic arduino coding skills that are covered in the intro courses. And BONUS - it's super fun for my kids!
The wiring and code are very simple, but with four switches, five LEDs, and a servo, it's the perfect project to do after learning the basics.
What It Does:
This project was inspired by the scene in Raiders of the Lost Ark where Indiana Jones steals the golden idol from the pedestal. In this case, the kids have to find the idols somewhere in our house, and place them on the pedestals in order to open the doors, and retrieve the hidden prize.
There is a lot you can do with this project once it's finished becuase you can hide the figurines and have the kids search for them using maps, clues, a treasure hunt, etc.
The four idols are mounted on magnets. The pedestals are each a magnet switch. Every time you place an idol on a pedestal, it's green LED lights up. Once all four idols have been place in a spot, the white LED lights up, and the doors swing open revealing the secret compartment.
Step 1: Parts List
- 5 LEDs. I recommend ones that come with 6" leads.
- 4 SPST normally open Magnet Switches and magnets. Round ones are easiest to install in this project, but any shape or size will work.
- 1 Servo. Any size will work, but tiny 9g is great, and cheap.
- 2 Shoes boxes
- Battery pack 4AAs
- 4 AA Batteries. Duh.
- Arduino Uno
- Jumper wires
- 9 330 Ohm resistors
- 1-4 Kids. Can be yours. Can be someone else's. If you borrow some, inform the parents.
- Hot glue gun
- X-acto knife
- Bandaids (to follow the exacto knife)
Step 2: Wiring
Use the graphic schematic to wire up the Arduino as shown. In this drawing, I purposefully ommited the breadboard because I think others might be able to come up with a more elegant layout than I did. This drawing will show you how to connect everything properly, but you can choose how to lay it out on the breadboard or PCB.
I did include a photo of my layout in case helpful!
Step 3: Code
As I mentioned, this project is great for beginners following the intro tutorials! You'll notice that all of the code comes directly from the intros, but is repeated several times because this project uses 4 "buttons" (in this case magnet switches), 5 LEDs, and a servo.
The concept is the idea of the "buttonSum" which is just a variable that stores how many of the switches are have been activated. Once buttonSum equals 4, the door opens.
Direct link to the sketch in Arduino Editor: https://create.arduino.cc/editor/opersing/68fd9f5f-e15b-4a2a-b6b9-e4076fe2beeb/preview
Step 4: Construction
I built this by gluing two separate boxes together. In this case, I repurposed old Kiwi Crates, but shoe boxes would work just as well! The key is to connect the two boxes in a way that you can access the innternal workings - both the Arduino, and the servo mechanism that opens the door.
For the bottom box, hotglue the Arduino and Breadboard in place so they don't slide around. I recommend using a box that has a connected flip lid. This will keep all of the cables to the LEDs and switches connected when you open the box.
Once you glue the Arduino down, punch holes in the lid of the box for the LEDs and magnet switches. The placement doesn't matter, I put them all in a row, and any magnet can activate any switch, so pick a layout you like.
The top box should be glued on top of the lower box standing up so the two boxes create an "L" shape. The top box should be glued to the lower box with it's bottom facing the switches and LEDs. This means that the top boxe's lid will make an excellent access panel for accessing the servo motor and door mechanism.