import RPi.GPIO as GPIO import time led_pin = 18 GPIO.setmode(GPIO.BCM) GPIO.setup(led_pin, GPIO.OUT) pwm_led = GPIO.PWM(led_pin, 500) pwm_led.start(100) # Brightness has to have a value between 0 and 100 # starts with 0 duty_s = 0 duty = int(duty_s) while duty < 100: pwm_led.ChangeDutyCycle(duty) duty+=20 time.sleep(1.5)