예제 #1
0
파일: rpiLed.py 프로젝트: SarathM1/RPi
def led_breathe(pin_no):
    """
	Fn to vary the duty cycle to   
	dim/brighten the leds
	"""
    pwm = PWM(pin_no, 100)  # create object for PWM on port pin_no at 100 Hertz
    pwm.start(0)  # start led on 0 percent duty cycle (off)
    for i in range(101):
        pwm.ChangeDutyCycle(
            i)  # Increase duty cycle from 0% to 100% (step by 1)
        time.sleep(0.03)
    for i in range(100, -1, -1):
        pwm.ChangeDutyCycle(
            i)  # Decrease duty cycle from 0% to 100% (step by 1)
        time.sleep(0.03)
    time.sleep(1)
    pwm.stop()  # stop the PWM output
예제 #2
0
 def __stop(pwm: GPIO.PWM):
     pwm.ChangeDutyCycle(0)
예제 #3
0
 def turn(self, pwm_turn: GPIO.PWM):
     self.__resetTurnPWMS()
     pwm_turn.ChangeDutyCycle(turn_duty)
     time.sleep(turn_slp_interval)
     pwm_turn.ChangeDutyCycle(0)