You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
919 B

import RPi.GPIO as GPIO #import GPIO Module
from time import sleep #sleep command
def SetAngleUp(angle):
GPIO.setmode(GPIO.BOARD) #pins naming
GPIO.setup(03, GPIO.OUT) #PWM signal output (GPIO2)
pwm=GPIO.PWM(03, 50) #50Hz PWM on pin
pwm.start(0) # start with 0 duty ccle (sets no angles on startup)
duty = angle / 18 + 2
GPIO.output(03, True)
pwm.ChangeDutyCycle(duty)
sleep(1)
GPIO.output(03, False)
pwm.ChangeDutyCycle(0)
pwm.stop()
GPIO.cleanup()
def SetAngleDown(angle):
GPIO.setmode(GPIO.BOARD) #pins naming
GPIO.setup(05, GPIO.OUT) #PWM signal output (GPIO3)
pwm=GPIO.PWM(05, 50) #50Hz PWM on pin
pwm.start(0) # start with 0 duty ccle (sets no angles on startup)
duty = angle / 18 + 2
GPIO.output(05, True)
pwm.ChangeDutyCycle(duty)
sleep(1)
GPIO.output(05, False)
pwm.ChangeDutyCycle(0)
pwm.stop()
GPIO.cleanup()
SetAngleDown(100)
SetAngleUp(100)