This guide will show you how to build your own chest secured with code. In addition, you will get to know the programming language Python through small tutorial blocks.
You will learn...
- ...retrieve data from a keypad.
- ...set up a small computer.
- ...to switch circuits with a relay.
- ...to control an LED.
- ...and many more things.
What are the functions of the LockSafe chest?
- You can think of your own 6-digit code.
- If you enter incorrectly too many times, lock the chest for 60 seconds.
- Lock your secrets in the chest
- and many more functions...
Now we come to the material. I have created a list of products that we need for you here below.
Note
You may already own a product. Therefore, only buy what you need.
- Raspberry Pico => Order with headers
- 12v plug with USB and DC plug
- MicroUSB JBL charging cable
- Keypad 3x4
- connecting cable
- plug-in board
- Wooden box with flat lid
- Relay
- Lock
Note
You only have to buy the following products if you want to use an LED:
First you have to install the software on the Raspberry Pico. Because Python is too big, we use Circuitpython. Hold down the Bootsel button (which is on the Pico's board) and plug the Pico into your PC using the JBL charging cable. Don't release the button until the pico appears on your PC. (like a USB stick)
Warning
Do not open any of the files that are on the Pico.
Now visit this website and download the file. When the download is complete, put the file on the Raspberry Pico. The Raspberry Pico then ejects itself automatically and is no longer displayed. Unplug the Pico and plug it back in. Then it should have the name Circuitpython.
Now visit this page and download the program. Run the file and open it.
If the console below does not say that the device was found, click Run -> Configure the interpreter -> Type: CircuitPython (generic) off in the menu.
If you still get an error, contact me at [email protected].
First, plug the pico into the breadboard:
Glue the breadboard (marked green) with the JBL connector (marked red) down in the box:
Also cut a hole for the cable. (marked blue)
First set the power supply to 12v on the back.
Glue the keypad to the front of the box and again cut a hole for these cables behind the keypad. Image:
Now plug in the keypad:
Now create a new file in Thonny. (If none is already displayed)
Paste this code:
import board
import keypad
import time
import digitalio
#Keypad pins used (GP Art)
rowPins = (board.GP10, board.GP11, board.GP12, board.GP13)
columnPins = (board.GP14, board.GP15, board.GP16)
#Create keypad matrix
keypadMatrix = keypad.KeyMatrix(rowPins, columnPins)
#key assignment
keyMap = { 0: "1", 1: "2", 2: "3", 3: "4", 4: "5", 5: "6", 6: "7", 7: "8" ,
8: "9", 9: "*", 10: "0", 11: "#" }
#LED on the pico will be activated to see that the program is running
led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
#Info
print("Press a key!")
#continuous loop
while True:
led.value = True
event = keypadMatrix.events.get()
if event:
if event.pressed:
print(keyMap[event.key_number])
time.sleep(0.5)
Now save the Python code with the name keypad_test.py. Now run the code with the arrow!
Install:
1.Hole in the front of the box where the engine clicks in
2.Screw the motor to the ceiling towards the front
3.Glue the relay next to the Pico with Tesa
Connect:
Warning
Leave the keypad plugged in! I've hidden it in the image because you've already installed it.
import board
import keypad
import time
import digitalio
#Signal pin connected to the relay
relay = digitalio.DigitalInOut(board.GP0)
relais.direction = digitalio.Direction.OUTPUT
#LED on the pico will be activated to see that the program is running
led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
#continuous loop
while True:
led.value = True
relay.value = True
time.sleep(2)
relay.value = False
time.sleep(2)
Now save the Python code with the name relais_test.py. Now run the code with the arrow!
Install:
All you have to do is...
...cut two holes next to the keypad.
...put the LEDs through. (Red and Green)
Plug in:
Warning
Leave the keypad, relays, motor and so on plugged in! I've hidden it in the image because you've already installed it.
import board
import keypad
import time
import digitalio
# LED setup.
led1 = digitalio.DigitalInOut(board.GP17)
led1.direction = digitalio.Direction.OUTPUT
#LED on the pico will be activated to see that the program is running
led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
#continuous loop
while True:
led.value = True
led1.value = True
time.sleep(2)
led1.value = False
time.sleep(2)
Now save the Python code with the name led_test.py. Now run the code with the arrow!
Note
Select to get the final code: