İçeriğe Geç

Projeler

#25 Safe Box Project With micro:bit

Tarafından PicoBricks Team 17 Jun 2025

The PicoBricks Pass Box is an educational project kit designed to create a pass box that automatically locks after assembling the wooden pieces and PicoBricks modules according to the installation steps. 

In this project, when the correct password is entered by using a potentiometer and button, the door of the safe opens. After closing the door, it automatically locks thanks to the LDR sensor inside the safe.

When we correctly enter the password we have set in the code by using the potentiometer and button module, the servo motor moves to the specified position, and the door opens. Through the LDR module, the closure of the pass box lid is detected, triggering the servo motor to operate and lock the door. We will create the code blocks that enable these functions. With the PicoBricks OLED display module and Micro:Bit Matrix LEDs in the Pass Box project, we will obtain visual output.

Connection Diagram:

You can assemble this project by breaking the PicoBricks modules at the proper points.

Project Images:


Setup Steps of The Project


MakeCode Code of The Project


Python Code of The Project:


#Safe Box Project
from microbit import *
from picobricks import *

# Pin Initialization
LDR_Pin = pin0
Pot_Pin = pin1
Button_Pin = pin2

# Function Initialization
oled = SSD1306()
oled.init()
oled.clear()
motor = motordriver()

display.show(Image.HAPPY)
password=[1,2,3,4]
userPass=[]

def startOLED():
    oled.add_text(0,1,"Close the lid")
    oled.add_text(0,2,"to lock the")
    oled.add_text(0,3,"SafeBox")
    
def addList():
    #counter=0
    if counter>0:
        oled.add_text(2,3,str(userPass[0]))
    if counter>1:
        oled.add_text(4,3,str(userPass[1]))
    if counter>2:
        oled.add_text(6,3,str(userPass[2]))
    if counter>3:
        oled.add_text(8,3,str(userPass[3]))

def controlLoop():
    control=0
    for i in range(4):
        if password[i]!=userPass[i] :
            control=1
    if control==1:
        display.show(Image.NO)
    else:
        display.show(Image.YES)
        motor.servo(1,90)
        sleep(3000)
        oled.clear()
            
        
                
while True:
    display.show(Image.HAPPY)
    counter=0
    startOLED()
    light = LDR_Pin.read_analog()
    pot = Pot_Pin.read_analog()
    button = Button_Pin.read_digital()
    print(light)
    if light<50:
        sleep(2000)
        oled.clear()
        motor.servo(1,180)
        while counter<4:
            pot = Pot_Pin.read_analog()
            userNumber=round(round( pot - 0 ) * ( 9 - 0 ) / ( 1023 - 0 ) + 0)
            oled.add_text(2,1,"Password:")
            oled.add_text((2+(counter*2)),3,str(userNumber))
            addList()
            button = Button_Pin.read_digital()
            if button==1:
                userPass.insert(counter,userNumber)
                counter=counter+1
                sleep(200)

        controlLoop()
    sleep(500)
    counter=0
    control=0

MicroBlocks Code of The Project

Önceki Gönderi
Sıradaki Gönderi

Abone olduğun için teşekkürler!

Bu e-posta kaydedildi!

Görünümü satın alın
Seçenekleri Seçin

Picobricks
Özel güncellemeler için kaydolun, yeni gelenler ve yalnızca içeriden öğrenenler için indirimler

Seçeneği Düzenle

Stok Bildirimi

Karşılaştır

Ürün Stok KoduDeğerlendirmeAçıklama Kategori Uygunluk Ürün Tipi Diğer Detaylar
this is just a warning
Giriş Yap
Alışveriş Sepeti
0 Ürünler
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment