Python Forum
Python with LED light strip question. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python with LED light strip question. (/thread-12067.html)



Python with LED light strip question. - Ostromaj - Aug-07-2018

I recently took up a project to try to mimic a game I saw in my childhood science center. It was a game where you could hit a button and have to race an animal via lit up bulbs that would light up down a long hallway and you’d basically have to beat the lights down the hallway by racing them. I’m newer to python and I’ve only been coding for about a year or two. I already have the game set up but I’m debating on what light strips to get(cost effective) that would be easiest to code with python. Also I haven’t coded the sunning of the light strips(because I don’t have them) All I want them to be able to do is when a button is clicked(on screen) pause for about 3 seconds.(3-2-1-go) then have one led light up down the whole strip to the end. Then I’ll also try my hand at having them all light up once it reaches the end. I’m between the SMD5050, SMD3528, or WS281x. Do they all require the same code or is one harder than the other?


RE: Python with LED light strip question. - Vysero - Aug-07-2018

This sounds great but Python alone isn't going to do it for you. Although, you can ultimately use Python to code your logic you need some type of peripheral device that will be able to control the voltage going in and out of the LED strip. If you want to use Python (not necessary btw) but if you do you can buy a rasberry pi and use the RPi library for Python.

All that being said if you are interested in this working in real time then Python is not the way you want to go. This is because you will never be able to predict when Python say... goes garbage collecting or something like that which will ultimatly interupt your program as its running.

If you want to work in real time I would suggest you use someting like an Arduino (I like the uno, cheap and easy), check out this link: https://store.arduino.cc/usa/arduino-uno-rev3


RE: Python with LED light strip question. - buran - Aug-07-2018

(Aug-07-2018, 05:39 PM)Vysero Wrote: All that being said if you are interested in this working in real time then Python is not the way you want to go. This is because you will never be able to predict when Python say... goes garbage collecting or something like that which will ultimatly interupt your program as its running.

say again.... I like to drink a cup of coffee while waiting python to finish garbage collecting... very convenient, no rush at all...

(Aug-07-2018, 05:39 PM)Vysero Wrote: If you want to work in real time I would suggest you use someting like an Arduino (I like the uno, cheap and easy), check out this link: https://store.arduino.cc/usa/arduino-uno-rev3
and use python https://www.google.com/search?q=arduino+and+python


RE: Python with LED light strip question. - Ostromaj - Aug-07-2018

I have a raspberry pi 3+. I’ve seen a few tutorials for Arduino/Pi. There’s one that uses the pigpio library and one that uses the neopixel and argparse libraries. I’m leaning towards using the pigpio one which uses the SMD5050s. Is there an easier library to learn ?


RE: Python with LED light strip question. - Vysero - Aug-07-2018

@buran To be completely honest I was just guessing when I made the point about garbage collection XD. In general, I wouldn't normally use Python to run I/O but I guess it was naive of me to think someone hasn't figure out a way to use it efficiently.

@Ostromaj I would just use whatever feels easier to you.


RE: Python with LED light strip question. - Ostromaj - Aug-07-2018

Thanks :)