This block initializes a Robotic Arm connected to a Quarky Expansion Board. The user can select the specific pin connected to the servo motors from a dropdown menu. Once initialized, the robotic arm will respond to code and be ready for further instructions.
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:
- Open – When the gripper servo motor angle is 0
- 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:
- 2 Key Control: In this method, the gripper will open when the “o” key is pressed and close when the “c” key is pressed.
- 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
- Open the Pictoblox application.
- Select the Block Coding Environment.
- Click on the Robotic Arm extension available in the left corner.
2 Key Control
Logic
- The code checks if the “o” or “c” buttons are pressed with an if statement.
- If the “o” button is pressed, it will open the gripper.
- If the “c” button is pressed, it will close the gripper.
- 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
- The code first sets the gripper to the “open” position.
- 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.
- 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.
- 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.
Read More