Zum Inhalt springen

Projekte

#19 Radar Project With micro:bit

von PicoBricks Team 02 Jun 2025

The radar is a device that detects objects in its surroundings, their direction of movement, their speeds, and other values through radio waves. The effective ranges, or ranges, of radars can vary. Depending on this variation, their applications change. Radars are frequently used to ensure security in various vehicles such as ships, airplanes, etc., and in military areas. 

Since radar operates with radio waves, which sensors on PicoBricks or in the set can we use to create a sample radar project? Among the PicoBricks modules and sensors in the set, the sensors with distance measuring capability are the Ultrasonic Distance Sensor (HC-SR04) and the gesture module. Due to the limited range of distances that the gesture module can measure, the ultrasonic distance sensor would be more suitable for a project of this kind.

Ultrasonic distance sensors detect objects around them by using sound waves. As explained in the diagram below, the distance to the object in front is determined by calculating the time it takes for the sound wave emitted from the Trig pin to hit the Echo pin.

In this project, we will create a radar project using the PicoBricks, ultrasonic distance sensor, and servo motor.

We will implement a radar project by rotating the servo motor connected to PicoBricks' motor driver based on the value detected by the ultrasonic distance sensor connected to the P1-P2 pins, within a 0-180 degree angle. The radar will move in the range of 0-180 degrees until it detects a value within the range determined by the potentiometer module. If an object is detected within the specified range, it will stop moving, emit a warning sound from the buzzer, and display the distance and angle of the object from the radar on the OLED screen.

Connection Diagram:

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


Project Images:

 

The STL Files of The Project


You can access the STL files of the project by scanning the QR code or opening the link in
your browser.

 https://rbt.ist/thingiverse

MakeCode Code of The Project


Python Code of The Project:


#PicoBricks Radar Project
from microbit import *
from picobricks import *
import music

# Pin Initialization
Button_Pin = pin2
Pot_Pin = pin1

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

motor.servo(1,90)
angleServo=0
radarRange=0
c=1
button = Button_Pin.read_digital()
while Button_Pin.read_digital()==0:
    oled.clear() 
    pot = Pot_Pin.read_analog()
    radarRange=round(round( pot - 0 ) * ( 100 - 0 ) / ( 1023 - 0 ) + 0)
    oled.add_text(0,0,"Radar Range:")
    oled.add_text(5,1,str(radarRange))
    sleep(50)
oled.clear()

while True:
    oled.clear()
    distance = measure_distance()
    while round(measure_distance())>= radarRange:
        oled.add_text(2,2,"Scaning...")
        motor.servo(1,angleServo)
        if c==1:
            angleServo=angleServo+5
        if c==0:
            angleServo=angleServo-5
        if angleServo==180:
            c=0
        if angleServo==0:
            c=1
        sleep(10)
    oled.clear()
    objectDistance=round(distance)
    oled.add_text(2,0,"Object")
    oled.add_text(2,1,"Detected!")
    oled.add_text(0,2,"cm:")
    oled.add_text(5,2,str(objectDistance))
    oled.add_text(0,3,"Degreess")
    oled.add_text(8,3,str(angleServo))
    music.play(['c'])


MicroBlocks Code of The Project

 

Vorheriger Beitrag
Nächster Beitrag

Danke fürs Abonnieren!

Diese E-Mail wurde registriert!

Shoppen Sie den Look
Wählen Sie Optionen

Picobricks
Melden Sie sich für exklusive Updates an, Neuankömmlinge und Insider-Rabatte

Bearbeitungsoption

Benachrichtigung wieder auf Lager

Vergleichen

Produkt ArtikelnummerBewertungBeschreibung Sammlung Verfügbarkeit Produktart Andere Details
this is just a warning
Anmeldung
Einkaufswagen
0 Artikel
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment