树莓派使用带有UART接口发送PELCO-D协议
import time
import serial
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT, initial = GPIO.HIGH)
send = serial.Serial(
port ='/dev/serial0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
i = [255,1,0,4,63,0]
for x in i:
send.write(bytes([x]))
time.sleep(0.1)
GPIO.output(7, GPIO.LOW)
GPIO.cleanup()