Secrets and Safes

TEAM - diya, ali, vedamsh
We decided to mimic an already existing solution and innovate with it, that is, using the motion sensor to detect infrared light waves and sound an alarm directly connected to the microbit. This innovation works by allowing you to take an item and not be detected when you activate a super secret cool button behind the box that rotates a servo attached to a high tech foil piece and covers the sensor, blocking infrared rays from passing through and when you press another one of these buttons, the foil is rotated back to its original hiding spot, and the sensor is back to functioning. Press button A to deploy the foil and cover the sensor and press button B to reset the alarm and let the motion sensor work.
Supplies




- gpio wires
- microbit v2
- microbit servo
- microbit infrared motion sensor
- 9v battery
- Microbit extension board
- carboard box
- tape
- scissors
- tin foil
The Code


This code includes functions to activate a motion sensor, trigger an alarm, and deactivate it. Under a forever loop, a function that checks the digital read from pin p8; if motion is detected, the sensor reads a value of 1, triggering the alarm that is under a loop function to repeat 4 times until the sensor is done detecting is written. The alarm sound can be modified to your liking but we used a melody combination of lower and higher beats. If no motion is detected, nothing happens. Pressing button A rotates a servo by 90 degrees with foil attached, blocking the sensor, allowing the user to grab items from the safe. The foil can be reset to its vertical position to restore normal sensor operation by pressing button B. The flowchart above explains how this code is meant to work to refer back to and underneath is the hex file to the code.
Downloads
Wiring


For the servo and the motion sensor, the use of the breadboard was not required, and included rather simple connections. So using gpio pins, to connect both, the motion sensor should have connections to 5V of power, digital read pin 8, and ground of i2c pins. The servo should have 5V power connections, a power ground connection, and be connected digital read pin 12 but these pin numbers can vary depending on your code and connect to the extension board.
Helpful Tips

One main issue was figuring out how the sensor worked and its range, mechanics, etc. In the above image, the left adjustable dial is the range, which can go from 3m-7m, with the left being the least and right being the most. On the right side, the second adjustable dial is for input delay, and ideally, you would want it to be as far left as possible for the fastest reaction time/lowest input time.
The Journey


The journey of this project involved a fair amount of trial and error, particularly with hardware related issues. While writing the code was relatively straightforward, adjusting the sensor's range, input delay, and fine tuning the alarm’s sound proved to be more challenging. We also had to grasp how infrared light works and find a flexible material that could effectively block it. Ensuring the wiring was correct and fully understanding the motion sensor required extensive testing and research. Through debugging and documenting each mistake, we continuously refined the design, working together to solve problems and ultimately create a functional device.
Proud Of
One major thing we were proud and happy about was understanding and making the motion sensor work as it took almost an entire week’s worth of frustrating lunches to get it to work and find the perfect range for the specific box we had.
Improvements That Could Have Been Made
To turn this into a product, my team would enhance the code to add multiple modes for the motion sensor, making it more versatile for larger items. The foil material would be upgraded for better reliability, as it currently works 85% of the time. The "secret" button and wiring would be more discreet and organized for a cleaner, more streamlined design. Additionally, a keypad would be added for locking and unlocking, along with an LCD display for messages like "welcome" or "leave" to improve security. The box design would be sleeker, and the sensor and servo mounts would be made more stable for long term reliability.
The Final Product


The final product is a security device using a microbit microcontroller, a motion sensor, and an alarm to protect valuable items in a locker, box, or safe. A secret button controls a servo that moves foil to block the sensor, allowing discreet access to items temporarily. After pressing another button, the foil resets, and the sensor resumes functioning. Key challenges included improving sensor reliability and organizing wires, but through collaboration and innovation, we created a functional, secure, and user friendly device that you can make too!