7.2.6 Gripper and Pump Control

Run these examples only after the relevant accessory is installed, wired correctly, and the work area is safe.

1. Adaptive Gripper

import time
from pymycobot import MyCobot280

mc = MyCobot280(unoq_bridge=True)
time.sleep(2)

# Open the gripper.
mc.set_gripper_state(0, 80, 1)
time.sleep(3)

# Close the gripper.
mc.set_gripper_state(1, 80, 1)
time.sleep(3)

print("gripper value:", mc.get_gripper_value())

You can also use set_gripper_value(value, speed, gripper_type) to specify the opening value. Do not test closing while hands or fragile objects are in the gripper.

2. Pump

The current example uses digital output 33 for the pump and 23 for the release valve. Verify actual wiring before running it:

import time
from pymycobot import MyCobot280

mc = MyCobot280(unoq_bridge=True)

def pump_on():
    mc.set_digital_output(33, 0)
    time.sleep(0.05)

def pump_off():
    mc.set_digital_output(33, 1)
    time.sleep(0.05)
    mc.set_digital_output(23, 0)
    time.sleep(1)
    mc.set_digital_output(23, 1)

pump_on()
time.sleep(2)
pump_off()

If the accessory model or wiring differs, confirm its IO and active level in the accessory documentation before using these pin numbers.

Previous: Coordinate Control | Back to Python Development | Next: Integrated Examples

results matching ""

    No results matching ""