Système PWM

Code test (LED)

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
LED = GPIO.PWM(4, 50)
LED.start(0)
try:
while 1:
for dc in range(0, 101, 1):
LED.ChangeDutyCycle(dc)
time.sleep(0.01)
for dc in range(100, -1, -1):
LED.ChangeDutyCycle(dc)
time.sleep(0.01)
except KeyboardInterrupt:
pass
p.stop()
GPIO.cleanup()

Retour

Projet Mariokart