Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -----------------------------------------
- # Imports
- # -----------------------------------------
- import os
- import time
- os.system ("sudo pigpiod")
- time.sleep(1)
- import pigpio
- # -----------------------------------------
- # Constant values
- # -----------------------------------------
- # Gpio pins
- MOTOR_1=24 # Right motor
- MOTOR_2=27 # Left motor
- MOTOR_3=20 # Right-Up motor
- MOTOR_4=5 # Left-Up motor
- # PWM values for the gio pins
- MAX_VALUE = 1900 # ESC's max value
- ZERO_VALUE = 1500 #ESC's zero value
- MIN_VALUE = 1100 #ESC's min value
- # -----------------------------------------
- # Initialization
- # -----------------------------------------
- pi = pigpio.pi();
- pi.set_servo_pulsewidth(MOTOR_1, 0)
- pi.set_servo_pulsewidth(MOTOR_2, 0)
- pi.set_servo_pulsewidth(MOTOR_3, 0)
- pi.set_servo_pulsewidth(MOTOR_4, 0)
- time.sleep(1)
- # 1500 sets the motor speeds off
- pi.set_servo_pulsewidth(MOTOR_1, ZERO_VALUE)
- pi.set_servo_pulsewidth(MOTOR_2, ZERO_VALUE)
- pi.set_servo_pulsewidth(MOTOR_3, ZERO_VALUE)
- pi.set_servo_pulsewidth(MOTOR_4, ZERO_VALUE)
- # -----------------------------------------
- # Method Definitions
- # -----------------------------------------
- def motor1_go(inp):
- pi.set_servo_pulsewidth(MOTOR_1,inp)
- def motor2_go(inp):
- pi.set_servo_pulsewidth(MOTOR_2,inp)
- def motor3_go(inp):
- pi.set_servo_pulsewidth(MOTOR_3,inp)
- def motor4_go(inp):
- pi.set_servo_pulsewidth(MOTOR_4,inp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement