Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- from time import sleep
- pwmpinL = 18
- pwmpinR = 19
- pwmfreq=10000 # set PWM frequency to 10Khz, compatible with slow slew mode on the motor controller
- dc = 50 # percent duty cycle to test with
- GPIO.setmode(GPIO.BCM) # set pin selection mode
- GPIO.setup(pwmpinL, GPIO.OUT) #set left motor's pin to output mode
- GPIO.setup(pwmpinR, GPIO.OUT) #set right motor's pin to output mode
- pwmL = GPIO.PWM(pwmpinL, pwmfreq)
- pwmR = GPIO.PWM(pwmpinR, pwmfreq)
- #GPIO.output(pwmpinL, GPIO.LOW)
- print("Here we go! Press CTRL+C to exit")
- pwmL.start(dc) #start running left motor at test duty cycle
- sleep(5)
- pwmL.ChangeDutyCycle(0) #stop left motor
- pwmR.start(dc) #start running right motor at test duty cycle
- sleep(5)
- pwmR.ChangeDutyCycle(0) #stop right motor
- #GPIO.output(pwmpinL, GPIO.HIGH)
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement