Case 1 - Detect the distance with the ultrasonic sensor

Part 1   Objective

After you compile the program, the stage displays the distance detected by the ultrasonic sensor in real time.

1.gif

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.

2.gif

3.gif

Update the firmware of Ultimate 2.0.

4.gif

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.

5.gif

Part 4   Practice

Change the distance output value by changing the distance between the ultrasonic sensor and the obstacle. The distance is detected and displayed on mBlock 5.
Was this article helpful?
4 out of 6 found this helpful

Comments

1 comment
  • Recently  I bought a Ultimate 2.0 Kit, so I've been looking forward for this kind of help.....thanks .

    0

Please sign in to leave a comment.