Now that we've got the board coded with CircuitPython, you can mount the servo motor to act as a lock inside the box. You'll also mount the Circuit Playground Express to the box, but with magnets so it can turn freely and rotate to the combination, so you can turn it like a dial to enter the right combination and unlock the safe!
To build the safe, first prepare the combination dial by affixing the metal pin back to the back of the Circuit Playground Express using the foam tape.
Now, place the Circuit Playground Express on the door (formerly the lid of the box) where you'd like the dial to be, and then place the magnet on the inside of the door so it sits at the center of the dial.
Use two pieces of tape to hold it down and prevent it from falling off.
Put batteries in the case.
Use the JST extension cable to extend the battery pack, then plug it into the Circuit Playground Express.
Hook the battery pack's clip to the flap on the wall at the back of the safe, leaving plenty of slack for the dial to turn.
Use the small servo arm like a wrench to turn the servo's shaft until it is at it's farthest counter-clockwise position when looking down at the shaft oriented as shown.
Remove and re-position the servo arm so that it points left at the 9 o'clock position as shown. It should be free to rotate to the 1 o'clock position, traveling counter-clockwise past 6 o'clock.
Screw in the small retaining screw into the center of the servo shaft to secure the arm.
Now, we can create the "lock". Use a small piece of double stick foam tape to affix the servo on top of the box so that the servo arm blocks the lid from opening as shown here.
In case you disconnected them after coding, re-connect the alligator clips back to the Circuit Playground Express as before:
- Red goes from VOUT to servo red voltage wire
- Black goes from GND to servo brown ground wire
- Yellow goes from A3 to servo orange signal wire
Turn on the battery pack, but leave the Circuit Playground Express unplugged, then close the door.
Now, place the "dial" over the chosen spot -- the magnet on the other side will hold it nicely in place.
Time to "arm" the safe! Plug in the JST connector. The system will boot up, and the servo arm will lock down into place.
Now, it's time to try out your safe!