Skip to content

Latest commit

 

History

History
164 lines (152 loc) · 7.93 KB

english.md

File metadata and controls

164 lines (152 loc) · 7.93 KB

Build a locksafe

1st preview

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...

2. Materials

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.

Note
You only have to buy the following products if you want to use an LED:

3. Set up Pico and Thonny

3.1 Connect Pico to PC

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.

3.2 Load Pico software

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.

3.3 Thonny

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].

4. Install pico in box

First, plug the pico into the breadboard:
alt text
Glue the breadboard (marked green) with the JBL connector (marked red) down in the box:
alt text Also cut a hole for the cable. (marked blue)

5. Keypad

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:
alt text
Now plug in the keypad:
alt text
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!

6. Relay and Lock

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.
alt text

code:
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!

7. LED (this step can be skipped if you don't want to include an LED)

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.
alt text

code:
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!

8. Summarize everything

Note
Select to get the final code: