-1

I have an LED display connected to a Teensy microcontroller using the FastLED library, which is connected to a Raspberry Pi Zero running Python via a USB hub.

I am looking for an existing library that handles the serial communication so that I can run commands in Python that trigger equivalent commands in FastLED on the Teensy efficiently and while respecting frame rate.

I've tried googling numerous times and searched the FastLED docs to see if there is something there. While there are many examples of code to drive LED displays via serial communication, I have not found a general library or package to do this.

E.g. What I'm looking for is something like this (simplified):

On the RPi:

dis = Display()
dis.connect()
for i in range(10):
 dis.setLED(i, (64, 0, 0))

Would cause the Teensy to execute:

leds[i].r = data[i];
leds[i].g = data[i + 1];
leds[i].b = data[i + 2];

I would expect other convenient functionality such as:

leds = [11, 15, 19]
data = [
 (32, 64, 96),
 (64, 32, 96)
 (96, 32, 64)
]
dis.setLEDs(leds, data)
data = ...
dis.setAllLEDs(data)
dis.clear()

That kind of thing.

Obviously, I can go ahead and write a library to do this myself but I can't believe it doesn't exist already so hoping someone will point me to something.

asked Feb 3 at 1:36
4
  • There was a similar question on Reddit 4 years ago: Is there a FastLED equivalent module for Python?. One answer includes a Micropython library. Commented Feb 3 at 1:40
  • On the Python (RPi) side use PySerial to send structured LED data. On the Teensy (FastLED) side read from serial and update FastLED accordingly. Commented Feb 19 at 17:57
  • @liaifat85 thanks for explaining how to do it. As I said, I could do this myself but I was hoping there was already a library for it. Commented Feb 19 at 20:41
  • Just found this library for handling Arduino serial communication, Serial_Packets, which can be paired with this Python library, serial-packets. Commented Apr 23 at 4:14

1 Answer 1

1

This isn't a perfect answer but it's the best I could find.

Robin2 on the Arduino Forum has written a good article on serial comms best practices and a demo of how to do communication between an Arduino and another computer running Python:

While not specific to operating LEDs, I found these resources very useful in writing my own code.

answered Mar 23 at 0:31
3
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. Commented Mar 23 at 0:47
  • @CommunityBot This answer provides two links to material that partially answers the question and a link to the author. I don't know any other way to cite web resources other than the URL, the author, and the date. Commented Mar 23 at 0:52
  • For anyone interested, I've now written updated Python 2 and 3+ versions of these scripts and published them here: github.com/billtubbs/pyserial-examples/tree/main/robin2_demo Commented Apr 5 at 21:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.