Part 1 Objective
After you compile the program, you can use the distance between the ultrasonic sensor and an object to control the opening and closing of the robotic clamp claw.
Part 2 Preparation
-
MegaPi x 1
-
MegaPi RJ25 adapter x 1
-
MegaPi encoder/DC motor driver x 1
-
Ultrasonic sensor x 1
-
RJ25 cable x 1
-
Plastic robotic clamp claw x 1
-
Robotic clamp claw cable x 1
-
USB cable (Type-B) x 1
-
Battery holder with 6 AA batteries x 1
-
Computer with network access x 1
Install the MegaPi RJ25 adapter and the MegaPi encoder/DC motor driver on MegaPi (the driver is connected to port 4A/4B in this program), connect the ultrasonic sensor to MegaPi by using the RJ25 cable, connect the plastic robotic clamp claw to any port for DC motor driver on MegaPi (select the port you connect to when you program, and the port selected here is 4B) by using the robotic clamp claw cable, connect the battery holder to MegaPi, 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.
Part 3 Programming
Use the wait until ( ) block from the Control blocks to perform actions under different conditions. In this program, the robotic clamp claw is closed when the distance between the ultrasonic sensor and an object is less than 10 cm, and it is open when the distance is larger than 10 cm.
Part 4 Practice
- Try to change the opening and closing speed of the robotic clamp claw.
- Try to change the opening and closing speed of the robotic clamp claw by changing the distance detected by the ultrasonic sensor. For example, the opening and closing speed decreases when the distance increases, and the speed increases when the distance decreases.
Comments
Please sign in to leave a comment.