Skip to content

Instantly share code, notes, and snippets.

@Hart87 Hart87/pigpio.py
Last active Sep 4, 2019

Embed
What would you like to do?
Calibrating and driving ESCs with PIGPIO & Raspberry pi
import pigpio
import time
#start the daemon - sudo pigpiod then check with pigs t
#stop the daemon - sudo killall pigpiod
## new PWM method
pi = pigpio.pi('localhost', 8888)
pi.set_servo_pulsewidth(26, 0)
pi.set_servo_pulsewidth(20, 0)
pi.set_servo_pulsewidth(19, 0)
pi.set_servo_pulsewidth(21, 0)
max_value = 2000
min_value = 1000
## calibr8
print('TURN IT ON HIGH')
for x in range(20):
print("plugin the battery.....")
pi.set_servo_pulsewidth(26, max_value)
pi.set_servo_pulsewidth(20, max_value)
pi.set_servo_pulsewidth(21, max_value)
pi.set_servo_pulsewidth(19, max_value)
time.sleep(1) #20 seconds on the highest pulse
#gradually turn it down to arm
for i in range(max_value,min_value,-1): #PULSING DOWN TO THE WEAKEST. EXPECTING THE ARMING BEEP
print(i)
pi.set_servo_pulsewidth(26, i)
pi.set_servo_pulsewidth(20, i)
pi.set_servo_pulsewidth(21, i)
pi.set_servo_pulsewidth(19, i)
print("Arming beep????")
time.sleep(10)
## drive it
for i in range(min_value,max_value,+1):
print(i)
pi.set_servo_pulsewidth(26, i)
pi.set_servo_pulsewidth(20, i)
pi.set_servo_pulsewidth(21, i)
pi.set_servo_pulsewidth(19, i)
time.sleep(.01)
#turn it down
for i in range(max_value,min_value,-1):
print(i)
pi.set_servo_pulsewidth(26,i)
pi.set_servo_pulsewidth(20,i)
pi.set_servo_pulsewidth(21, i)
pi.set_servo_pulsewidth(19, i)
time.sleep(.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.