Skip to content

Projects

#24 Money Box Project With micro:bit

by PicoBricks Team 16 Jun 2025

PicoBricks Money Box can detect objects placed in its receptacle through distance sensor in the front of it and automatically lifts its receptacle to take in these objects.

In this project, when the distance sensor detects the object placed in the receptacle , the servo motor connected to the motor driver is adjusted to the angle specified in the code, and then the object inside the receptacle is dropped into the Money Box.

Connection Diagram:

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

Project Images:


Setup Steps of The Project


MakeCode Code of The Project


Python Code of The Project:


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

# Function Initialization
motor = motordriver()
motor.servo(1,180)

trashDetected=0
distance=100

while True:
    rawdistance=measure_distance()
    if rawdistance<1200:
        distance=rawdistance
    motor.servo(1,180)
    sleep(500)
    if distance<5:
        trashDetected=1
        sleep(300)
    if distance>9 and trashDetected==1:
        trashDetected=0
        motor.servo(1,90)
        sleep(500)

MicroBlocks Code of The Project

Prev Post
Next Post

Thanks for subscribing!

This email has been registered!

Shop the look
Choose Options

Picobricks
Sign Up for exclusive updates, new arrivals & insider only discounts

Edit Option

Back In Stock Notification

Compare

Product SKURatingDescription Collection Availability Product Type Other Details
this is just a warning
Login
Shopping Cart
0 items
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment