Case 7 - Robotic Clamp Claw Control with Ultrasonic Sensor

Case 7 - Robotic Clamp Claw Control with Ultrasonic Sensor

 

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.

24.gif

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, web version, or mobile app), click +add, select Ultimate 2.0 from Device Library, click Connect, and select the Live mode.

25.gif
26.gif

Part 3   Programming

Robotic clamp claw control with ultrasonic sensor: 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 10cm, and it is open when the distance is larger than 10cm.

27.gif

Part 4   Practice

  1. Try to change the opening and closing speed of the robotic clamp claw.

  2. 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.

 

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.