I want to dim a LED with a Raspberry Pi 3. It works in loop perfect. But how do I dim the LED let's say 50% constantly? Without the script running in a loop. I want to start the python script that dims the LED and then stop it and the LED should still be dimmed. Is that even possible? The problem is, when I keep running the script the whole time, the CPU load of the Raspberry is very high (the whole time).
This is my code with the loop that works. I just want to remove Line 10, but then it doesn't work anymore. I'm a total python beginner.
import RPi.GPIO as IO
import time
IO.setwarnings(False)
IO.setmode (IO.BCM)
IO.setup(19,IO.OUT)
p = IO.PWM(19,100)
p.start(0)
while 1:
p.ChangeDutyCycle(50)