jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.78k stars 622 forks source link

Settings with timer like cron #457

Open Ericd140 opened 3 years ago

Ericd140 commented 3 years ago

Hello I am very new to script writing and using this LED strip lighting program. I have been trying to make the lights turn off and on with a scheduler like cron. i am basically looking to start the lights with the python script I made at 1900 and go off at 0000. Is there something you would recommend that would work? i cant seem to get it to function trying different ways.

Thanks!

Xartrick commented 3 years ago

Hi Ericd140, can you give us snippets of what you already tried so we can better help you?

As the script is running in loop, you must kill the process driving your LEDs before running it again. Cron's timeout can help in this case.

0 19 * * * timeout 5h python3 script.py

This will starts a script everyday at 19:00 and kill 5 hours later, giving 00:00.

Don't forget to add this to your crontab as root, root access is required to drive LEDs (sudo crontab -e).