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.ultraArmP340 import ultraArmP340
import time
#Enter the above code to import the package required by the project
<<<<<<< HEAD
# The ultraArmP340 class initialization requires two parameters:
# The first is the serial port string, such as:
=======
# ultraArmP340 类初始化需要两个参数:
# 第一个是串口字符串, 如:
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
# linux: "/dev/ttyUSB0"
# windows: "COM3"
# The second is the baud rate: 115200
#
# for example:
# linux:
# ua = ultraArmP340("/dev/USB0", 115200)
# windows:
# ua = ultraArmP340("COM3", 115200)
#
<<<<<<< HEAD
# Initialize an ultraArmP340 object
# Below is to create object code for Windows version
ua = ultraArmP340("COM3", 115200)
# Ultra Arm must return to zero before performing coordinate movement and angle movement, otherwise it cannot obtain correct angle coordinates
=======
# 初始化一个ultraArmP340对象
# 下面为 windows版本创建对象代码
ua = ultraArmP340("COM3", 115200)
# ultraArmP340进行坐标运动/角度运动之前必须进行回零,否则无法获取到正确的角度/坐标
>>>>>>> 482c782c42e70f0b2e44445345f6461e795f9189
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)