setGripperState(byte mode, int sp);
Function: Set the opening and closing status of the gripper
Parameter Description:
mode, jaw opening and closing mode, range 0/1, 0--jaw open to the maximum, 1--jaw closed to the minimum
sp, jaw opening and closing speed, range 1-100
setGripperValue(int data, int sp);
Function: Set the jaw opening and closing angle
Parameter Description:
data, jaw opening and closing angle, range 0-100, 0--closed to the minimum angle, 100--open to the maximum angle
sp, jaw opening and closing speed, range 1-100
Return value: None
setGripperIni();
Function: Set the gripper zero point
Return value: None
getGripperValue();
Function: Get the current angle of the gripper
Return value: Returns the current gripper angle, ranging from 0 to 100
isGripperMoving();
Function: Detect whether the gripper is moving
Return value: 0: not moving, 1: moving
void setGripperMode(bool mode);
Note: This interface is only available for MyCobot320 robots
Function: Set the adaptive gripper control mode
Parameter Description:
mode: mode, 0/1, 0--485 communication control, 1--io control (in io mode, it can only be turned on or off, and the angle cannot be set. When pins 23 and 33 are turned on or off, both pins need to be set to different states, one high and one low)
Return value: None
bool getGripperMode();
Note: This interface is only available for MyCobot320 robots
Function: Set the adaptive gripper control mode
Return value: Adaptive gripper control mode, 0/1, 0--485 communication control, 1--io control
This example will initialize the MyCobotBasic instance, turn on the robot power, and initialize the adaptive gripper. During the initialization process, the gripper will open and close once. After that, the gripper is controlled to reach two specified positions, then open and close once, and the program ends.
x#include <MyCobotBasic.h>
MyCobotBasic myCobot;
void setup()
{
myCobot.setup(); // Required API
delay(100);
myCobot.powerOn(); // Power on the robot arm
delay(100);
GipperInit(); // Initialize the adaptive gripper
}
void loop()
{
myCobot.setGripperValue(80, 50); // Open the gripper to 80° at a speed of 50
delay(500); // Once in place, proceed to the next step
myCobot.setGripperValue(20, 50); // Open the gripper to 20° at a speed of 50
delay(500);
myCobot.setGripperState(0, 30); // Fully open the gripper at a speed of 30
delay(600);
myCobot.setGripperState(1, 30); // Fully close the gripper at a speed of 30
delay(600);
}
void GipperInit()
{
myCobot.setGripperMode(0);
delay(100);
myCobot.setGripperState(0, 100); // Fully open the gripper at a speed of 100
delay(200);
myCobot.setGripperState(1, 100); // Fully close the gripper at a speed of 100
delay(200);
}