Part 1 Objective
After you compile the program, the stage displays the distance detected by the ultrasonic sensor in real time.
Part 2 Preparation
MegaPi x 1
MegaPi RJ25 adapter x 1
Ultrasonic sensor x 1
RJ25 cable x 1
USB cable (Type-B) x 1
Computer with network access x 1
Install the MegaPi RJ25 adapter on MegaPi, connect the ultrasonic sensor to MegaPi by using the RJ25 cable, connect MegaPi to the computer by using the USB cable, open mBlock 5 (PC client or web version), click +add, select Ultimate 2.0 from the Device Library, click Connect, and select the Live mode.
Update the firmware of Ultimate 2.0.
Part 3 Programming
In Live mode, after you select the check box on the left of the ultrasonic sensor port 6 distance (cm) block, the stage displays the distance detected by the ultrasonic sensor in real time.