Introduction: Build a Safe Using a Rpi
Want to learn how to convert your Raspberry pi into a fully functioning safe? Then follow this 12 step instructable to learn how. The safe will have a fully functioning keypad and a locking system, so you can keep your belongings safe.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials
Before getting started you need to collect the necessary materials. You will need:
- Push Buttons x9
- RGB Led x1
- Green LED x3
- DC Motors x2
- L292D H-bridge x1
- 330Ω resistor x4
- Breadboard x2
- T-cobbler x1
- Same sized gears x2
- Assortment of jumperwire's
- Glue Gun and Glue sticks
- Small hand saw
- Shoe box/cardboard box x1
- Wooden Dowel x2
- Multiple pieces of cardboard
- Black and Silver paint
- Electrical tape
- A straw or marker cap (large enough that the wooden dowel just passes through)
Step 2: Setting Up the Buttons
In this step you will need one breadboard, a T-cobbler, nine push buttons, and an assortment of jumperwire's. First place the T-cobbler on either end of the breadboard, make sure that it is placed over the center of the breadboard. Then place a blackwire with one end connected to the GND on the T-cobbler and the other side to the ground rail on the breadboard. Repeat the last step, but use a red wire and connect it from the 5V on the T-cobbler to the power rail on the breadboard. Place eight of the buttons on the breadboard in an 4 x 2 rectangular fashion leaving space between each button, place half of the buttons on each side of the breadboard. Then place the last button further down on the breadboard alone. The 4 x 2 rectangle of buttons is the keypad for the safe and the singular button is the reset button. To connect a button (any of the push buttons) use a blackwire to connect it to the ground rail, place one end of the blackwire in the ground rail and the other side in the same row as the button. Then connect the pin of the button that is on the same side as the pin you just connected to ground to a gpio pin on the T-cobbler. Repeat this for all nine buttons, so each button has its own gpio pin and is connected to ground.
Step 3: Setting Up the RGB LED
In this step you will need a RGB LED, one 330Ω resistor, an assortment of jumperwire's, and the breadboard from the past step. First place your RGB Led on year breadboard next to the reset button, make sure that each pin is placed in a separate row on the breadboard. Connect the longest pin of the RGB Led to the power rail using the 330Ω resistor. Then using jumper wires connect each of the other three legs of the RGB LED to a gpio pin.
Step 4: Setting Up the LED's
In this step you will need three green LED's, three 330Ω resistors, an assortment of jumper cables, a new breadboard, and the breadboard from the previous step. First connect the two breadboards together, connect the new breadboard on the right side of the breadboard from the previous step. On the new breadboard place a blackwire with one end connected to the ground pin on the T-cobbler and the other side to the ground rail on the breadboard. Then use a red wire and connect it from the 5V pin on the T-cobbler to the power rail on the breadboard. Place the three LEDs in a line, make sure each leg of each LED has its own row and there is space between each LED. Using the three 330Ω resistors connect the short leg (cathode) of each LED to the ground rail. Then connect the long leg (anode) of each LED to a gpio pin on the T-cobbler.
Step 5: Setting Up the Motors
In this step you will need an L292D H-bridge, two DC motors, an assortment of jumper cables, and the two breadboards from the previous step. Using the breadboard without the T-cobbler, place the H-bridge over the centre of the breadboard with the grove in the H-bridge facing the top of the breadboard, make sure each pin of the H-bridge has its own row on the breadboard. First connect the top and bottom pin on each side of the H-bridge to the power rail using red wires. Then using black wires connect the middle two pins on each side of the H-bridge to the ground rail. At this point there should be four pins on each side of the H-bridge with no connection. Using yellow wires connect the pins above/below the red wires to different gpio pins on the T-cobbler, make sure each pin connected with a yellow wire has its own gpio pin on the T-cobbler. Now connect a red wire and blackwire to each of the motors. At this point you should have two pins on each side of the H-bridge with no connections, on each side of the H-bridge place the red wire from one motor in the empty pin above the two middle blackwires. Finally on each side place the black wire from on motor in the empty pin.
Step 6: Code
Now that you have built your circut, boot up your Raspberry pi and open python (Idle) 3. Use this code to make your creation come to life, make sure to change the gpio pins to specify to your specific circut.
from gpiozero import LED, Button, RGBLED, Motor
from time import sleep
rainbow = RGBLED(red=16, green=25, blue=6)
led1 = LED(23)
led2 = LED(18)
led3 = LED(22)
resetbutton = Button(27)
button1 = Button(26)
button2 = Button(19)
button3 = Button(5)
button4 = Button(13)
button5 = Button(20)
button6 = Button(21)
button7 = Button(12)
button8 = Button(24)
motor = Motor(forward=4, backward=17)
motor2 = Motor(forward=8, backward=7)
rainbow.color = (0, 1, 0)
rainbow.color = (0, 1, 0)
if button1.is_pressed or button3.is_pressed or button8.is_pressed or button4.is_pressed or button6.is_pressed:
if button7.is_pressed and led1.is_lit:
if button5.is_pressed and led1.is_lit and led2.is_lit:
if led1.is_lit and led2.is_lit and led3.is_lit:
rainbow.color = (1, 0, 1)
Step 7: Build the Lock Mechanism
In this step you will need a hand saw, a glue gun, one wooden dowel, two gears (same size), two marker caps or straws, two DC motors, electrical tape, cardboard, and black paint. First get a 5cm x 5cm piece of cardboard and paint it black, then using the hand saw make grooves in the wooden dowel that match the groves on the gears. Create 7 to 10 groves in the wooden dowel, make sure to leave about 1.5cm of the dowel ungrooved at the front and about 0.7cm at the back. Now is using a straw cut two pieces of straw roughly 0.7cm in length, if using a marker cap use the hand saw to cut 0.7cm pieces of the cap. Now attach the gear to the motor, you can either hot glue the gear to the end of the motor or use electrical tape (hot glue works best). Now place and hot glue the pieces of straw/marker cap on the edge of the piece of cardboard, make sure that the two pieces of straw/ marker cap are one gears length apart and they are aligned so the wooden dowel can pass through them. Then cut the cardboard into a 5cm x 3cm, make sure the straw/marker cap pieces are along the edge of the 5cm side. Now cut a 1 - 2cm piece of dowel and place and hot glue it roughly 1cm behind the second straw/ marker cap, this dowel acts as a stopper. Now place the dowel with the gear groves in the straws/marker caps. Now cut a square into the cardboard between the two pieces of straw/marker cap, make sure you don't cut away the cardboard under the dowel. Now place the motor in the square shaped hole you just made in the cardboard, aline the gear groves with the ones on the dowel, the tape or hot glue the motor to the cardboard. Now repeat this step to create a second lock mechanism, make sure that the second lock mechanism is built so the dowel is facing the opposite way when the motors on each mechanism is facing the same way.
Step 8: Build Safe and Install Breadboard
In this step you will need a glue gun, the two breadboards from the previous steps, shoebox/box, cardboard, electrical tape, and black paint. To start off paint the whole shoebox black and cut another piece of cardboard that is the same length as the shoebox and the same height as the inside of the box, paint this piece of cardboard black as well. Next place your breadboard inside the shoebox in the front right corner, make sure the T-cobbler is facing the opposite side of the box and not up against the wall of the box. Next place and hot glue the piece of cardboard you just painted right behind the breadboard. Now cut and paint a piece of cardboard that is the size need to cove from the piece of cardboard you just glued to the front of the shoebox, this is to cover the breadboard in the box. Once painted add the new piece of cardboard by taping it to the other piece of cardboard that is already in the box, so the breadboard is still accessible when the cardboard is lifted.
Step 9: Create Keypad
In this step you will need the shoebox from the previous step, cardboard, scissors, and silver paint. First cut five different pieces of cardboard. Cut two 11cm x 4cm pieces, two 6cm x 4cm pieces, and one 11cm x 6cm piece. In the 11cm x 4cm pieces and the 6cm x 4cm pieces mark a dot in the center of each piece, then draw a line through the dot with 1cm on either side of the dot. Next cut to the edges of the line from the two bottom corners of the piece and then horizontally from the edges of the cardboard. Now each piece except the 11cm x 6cm piece should look like a rectangle with a triangle attached to the bottom of it. Next paint each piece silver, then glue all of these piece together to create a rectangular prism with no back side, the triangles on each side piece should be facing down. Now use the scissors to make a 4 x 2 grid to fit the 8 push buttons that are on your bread board, then cut holes for the reset button, the RGB LED, and the three green LED's. Next remove the nine push buttons, ther RGB LED, and the three green LED's from your breadboard and place them in the holes you just made for them in the keypad.
Step 10: Install Keypad
In this step you will need the keypad, the shoebox, an assortment of jumper wires, and scissors. First using scissors cut four slits on the front of the shoebox on the side that the breadboard is. The slits should match the triangles on the keypad, yet the cuts on the shoebox should be shorter than the length of the triangles. Next make a hole in between all of the slits on the shoebox. Now using jumper wires connect the buttons and LEDs to the breadboard were they were place previously, Feed the wires from the buttons and LEDs through the hole in the shoebox to the breadboard. Then place the keypad on the shoebox by inserting the triangles on the keypad into the cuts on the shoebox.
Step 11: Install Lock Mechanism
Finally to install the lock mechanism you will need a glue gun, the lock mechanisms, and scissors. On each lock mechanism there should be over hanging cardboard, use this to glue one mechanism on each side of the shoebox, on top of the cardboard covering the breadboard. Then make a hole in each side of the shoebox and the lid of the shoebox, the holes should line up with the wooden dowels on the lock mechanism. Now make a small hole in the cardboard covering the breadboard, through this hole connect the motors to the breadboard using jumper wires. Connect the motors to the H-bridge where they were originally placed in step five.
Step 12: FINISHED!
Now you have a fully functioning safe that you can run using your Raspberry pi, if you want the safe to be portable away from your monitor use VCN viewer to remotely connect to your pi. When using VCN viewer the Raspberry pi can be placed in the same compartment as the breadboard. Now you can stop worrying about your items and keep them safe. =)