Table of Contents
Example Description
Learn how to control a gripper using two different methods: 2-keycontrol, which activates when either the 'o' or 'c' key is pressed, and 1-key control, which activates when the 'space' bar is pressed.

Introduction

The gripper is used to pick and place any object. We are going to learn how to control it in this example.

The gripper has 2 states:

  1. Open – When the gripper servo motor angle is 0
  2. Close – When the gripper servo motor angle is 50

Control Logic

Now there are many methods to control the gripper. We will discuss 2 methods:

  1. 2 Key Control: In this method, the gripper will open when the “o” key is pressed and close when the “c” key is pressed.
  2. 1 Key Control: In this method, the gripper will open and close with only 1 key – “space”.

Let’s see how they work.

Setup PictoBlox

  1. Open the Pictoblox application.
  2. Select the Block Coding Environment.
  3. Click on the Robotic Arm extension available in the left corner.

2 Key Control

Logic

  1. The code checks if the “o” or “c” buttons are pressed with an if statement.
    1. If the “o” button is pressed, it will open the gripper.
    2. If the “c” button is pressed, it will close the gripper.
  2. The forever loop allows for the if statement to evaluate continuously.

Run the code to check the working of the gripper:

1 Key Control

Logic

  1. The code first sets the gripper to the “open” position.
  2. The code then enters an infinite loop, where it checks if the “space” button is pressed. If it is, it checks the current state of the gripper.
    1. If the gripper is in the “Open” state, it executes the “close” command and changes the state to “Close”. It then waits 0.2 seconds.
    2. If the gripper is in the “Close” state, it executes the “open” command and changes its state to “Open”. It also waits 0.2 seconds.

Conclusion

In this project, we learned how to control the gripper using two different methods. The first was 2-key control, which activated when either the ‘o’ or ‘c’ key was pressed. The second was 1-key control, which activated when the ‘space’ bar was pressed. Both were able to accurately open and close the gripper and can be used in robotics applications.