Surprise Box
This project was built in the context of a prototyping class.
The goal of this project was to create a surprise box that remains closed, emits green light inside when it is dark in the room, and opens, emits red light and sound, revealing a figurine when the room light is turned on.
Supplies
- Arduino Uno
- Stepper motor
- 1 LED
- 1photoresistor
- Active Buzzer module
- PLA for some element 3D printed
- 6mm wood for box and rail
- 2 nails
- spring
Test Components
First, you need to test every component.
Use stepper library examples to test the motor and general examples to test the LED and the buzzer.
Design and Make the Box and Lifting System
Firstly, the box needs to be designed and manufactured using a laser cutter. It is a cube with a side length of 19.2 cm, and cohesion between the different faces is ensured through a slotted cutting of the edges of each plate, allowing them to fit together through friction. The hinge is also made of wood and consists of two assemblies: a disk and rings. The disk is attached to the lid, rotating inside the ring, which is attached to the rest of the box. To achieve a cleaner finish, the edges of the lid have been fabricated using PLA with a 3D printer.
Moreover, to artificially lighten the box lid and facilitate opening by the figurine, a spring is attached to the lid and the back of the box. The spring is tensioned when the box is closed, exerting a force that aids in the opening of the box when triggered by the figurine.
Next, the system consisting of a gear connected to the motor and a rack to lift the platform on which the figurine is placed has been fabricated using PLA with a 3D printer. The radius of the gear is 2 cm to ensure that it exerts sufficient force on the rack, allowing the force exerted by the figurine on the lid as it ascends to be enough to open the box. Additionally, the module of the gear is 10, which is a good compromise between tooth strength and minimizing jerks during the system's operation.
Furthermore, it is also necessary to create a support for the motor. This support must prevent the motor from vibrating while positioning it high enough so that the gear is placed sufficiently high on the rack to lift it to a height that allows the figurine to be fully revealed when the box opens.
Finally, 2 holes are made, one in the back large enought to let power cable go into the box and be linked with Arduino card and the other to let the sensor of potoresistor be out of the box.
Write the Code
The objective of the code is to make the motor turn counterclockwise, the LED emit red light, and the buzzer work when the box is in darkness. The LED should emit green light and make the motor turn clockwise when the box is in the light.
To achieve this, the algorithm is based on a double "while" loop. One loop corresponds to the case of darkness, and the other to the case of light. The case is determined by the measurement of the resistance of the photoresistor, which has to be under a threshold in the case of darkness and over it in the case of light. The threshold depends on ambient light and has to be determined using the Arduino monitor.
Downloads
Assemble Every Elements Togethers
Once all components and the code are ready, the box can be finished.
First, use a laser cutter to create two rectangles of 30*150mm from wood to make a slider for the rack, allowing it to be elevated straightly. Additionally, add other smaller rectangles to link the platform that carries the figurine, and three more to keep the rack straight. Then, stick the pieces together to build the slider (see picture). Ideally, glue the slider close to the center to have the figurine centered. Moreover, try to position the platform as high as possible to keep the figurine low enough to close the box.
Once you attach the slider to the box, you can establish connections between the Arduino, LED, buzzer, and the controller to control the motor (see picture).
Next, place the motor in its structure next to the rack, fix the LED on the motor, and the box is ready!