8、Control suction pump

Connection

Firstly, we need to power the sunction pump as shown in the picture

Next we need to connect sunction pump and myCobot, using control cables. Connect 2 and 5 in the pin port. As shown in the picture.

Introduction of API

set_basic_output(pin_no, pin_signal)

Function:By connecting pin_no and control signal pin_signal to control external devices.

Parameter Description:

Pin_no:The int type parameter, the number of the label at the bottom of the device takes only the numeric portion.

Pin_signal:1 means stop running, 0 means run.

Content of code

from pymycobot.mycobot import MyCobot
from pymycobot import PI_PORT, PI_BAUD  # When using the Raspberry Pi version of myCobot, you can refer to these two variables for MyCobot initialization
import time

# Initialize a MyCobot object
mc = MyCobot(PI_PORT, PI_BAUD)

# Open sunction pump
def pump_on():
    # Let 2 work
    mc.set_basic_output(2, 0)
    # Let 5 work
    mc.set_basic_output(5, 0)

# Stop sunction pump
def pump_off():
    # Let 2 stop working
    mc.set_basic_output(2, 1)
    # Let 5 stop working
    mc.set_basic_output(5, 1)


pump_off()
time.sleep(3)
pump_on()
time.sleep(3)
pump_off()
time.sleep(3)

results matching ""

    No results matching ""