| 1234567891011121314151617181920212223242526272829303132 |
- import pigpio
- import subprocess
- import time
- subprocess.run('pigpiod', shell=True)
- pi = pigpio.pi()
- MSLIST = [
- {
- "name": 'MOTOR',
- "pinList": [13, 16]
- },
- {
- "name": 'SERVO',
- "pinList": [12, 19]
- },
- ]
- # 自动校准
- speed = 0
- while True:
- speed += 1
- for s in MSLIST:
- for d in s['pinList']:
- if s['name'] == 'MOTOR':
- # Set ESC speed via PWM
- pi.set_servo_pulsewidth(
- d, speed * 1000 / 7 + 1000)
- else:
- pi.set_servo_pulsewidth(d, 1500)
- time.sleep(2)
- print(speed)
- if speed > 3:
- break
|