IO control

IO refers to the input and output of data. There are multiple pin pins on the Basic and Atom of our mechanical arm, and its input and output modes can be set through the following function interfaces.

1 Basic IO

1.1 set_gpio_state(state)

  • Function: Set suction pump status。
  • Parameter description:
    • state (int):Input 0 to turn on the suction pump, and input 1 to turn off the suction pump.
  • Return value: None

2 Case

from pymycobot.ultraArm import ultraArm
import time
#Enter the above code to import the package required by the project

# The ultraArm class initialization requires two parameters:
#   The first is the serial port string, such as:
#       linux: "/dev/ttyUSB0"
#       windows: "COM3"
#   The second is the baud rate: 115200
#
#   for example:
#         linux:
#              ua = ultraArm("/dev/USB0", 115200)
#           windows:
#              ua = ultraArm("COM3", 115200)
#
# Initialize an ultraArm object
# Below is to create object code for Windows version
ua = ultraArm("COM3", 115200)

# Ultra Arm must return to zero before performing coordinate movement and angle movement, otherwise it cannot obtain correct angle coordinates
ua.go_zero()
time.sleep(0.5)

# Start suction pump    
ua.set_gpio_state(0)

#Wait for 2 seconds
time.sleep(3)


# Close the suction pump
ua.set_gpio_state(1)

time.sleep(2)

results matching ""

    No results matching ""