Fading aquarium LED strips in and out with PWM in Python
i work rotating shifts, so my planted tank never got a steady light cycle until i put a small LED strip on a Raspberry Pi and let it fade in by itself.
Cron starts the script at 18:00 and the loop below raises the duty cycle one percent at a time. The full ramp takes twenty minutes, about as long as the warm-up before an evening tip-off at Quezon City Basketball Club this week.
from gpiozero import PWMLED
from time import sleep
led = PWMLED(18)
for step in range(101):
led.value = step / 100
sleep(12)
anyone know a clean way to resume the ramp if the pi reboots halfway... thanks in advance 🌱
All rights reserved