Multiple light patterns using FastLED

Status
Not open for further replies.

Paul S

Active member
Hello,
I am looking for some input or direction to links that could help me out. I have a wearable light project. I am using a Teensy 3.2 and Bluetooth to send commands from my Android phone. The lights I am using are WS2812B. I am currently using the Adafruit_Neopixel Arduino library but want to change to FastLED. I understand that FastLED is faster and more capable. I currently have four light patterns and want to add more. The interface I have from my phone to the Teensy was made using App Inventor. Basically I press a button on my phone that sends a signal stating which pattern to run. I am using code from Adafruit that works with multi-tasking. (reference https://learn.adafruit.com/multi-tasking-the-arduino-part-3/overview?view=all) This code is useful in that I can “interrupt” code mid run and have minimal lag.
So, the help I am looking for is how can I add multiple patterns / sketches in to one sketch and control it from my phone using FastLED and not have any lag from changing from one pattern to the next? I have searched for FastLED and multiple sketches in one but have not been successful yet. I want the multi-tasking abilities and not have to deal with the issues the multi-task article describes regarding interrupts and having to wait for the cycle to complete before the command is recognized and implemented.
Thanks
 
Look at the DemoReel example, it's basically what you want to do. Instead of switching patterns via a timer like the example you'd switch from your phone signal.
 
Paul S, sorry to burst your bubble there is no such thing as multitasking on a single threaded process without a true multithreading core.
just to be clear, millis(), which is what adafruit's "multitasking" is using in it's example, is an exageration, the leds are updated bit by bit on a sequential basis, and never consistantly ran on it's own. there is no reason you can do the same on fastled using millis or elapsedmicros without the extra overhead of adafruit's special "multitask" library.
 
Thanks tonton61, no bubble burst. I take it you meant to say "there is no reason I can't do the same". All I am ultimately interested in is being able to change patterns with out any lag. I'll look in to using millis.
 
Thanks potatotron, where do I find the DemoReel? Is it a default pattern on the Arduino IDE?
 
Thanks potatotron. It dawned on me to search for it, DUH! And I found it. I am looking it over right now.
 
How many LEDs are you using?

With WS2812, each LED requires 30 us to update. So if you have 100 LEDs, that will take 3 ms.

You should use Serial1 or Serial2, because they have 8 byte FIFOs. That means they can tolerate 8 bytes arriving during the LED update time. You'll want to configure a baud rate slow enough so no more than 8 can occur. Serial uses 10 bits per byte (2 extra are start & stop bits). So if you divide 3 ms by 80 bits, that means 37.5 us/bit should be maximum safe speed. That's 26666, so using 19200 baud should be ok. Of course, as you have longer LED strips, the updates take more time.

The other thing you can do is use OctoWS2811. It's massively overkill for smaller LED projects, and it burns up many pins. But it doesn't disable interrupts, so you can do fast communication at any time. If you don't need those pins, you could connect LEDs to just one of the 8 outputs and allow the 7 others and lots of RAM to go unused.
 
Thanks Paul. I should have included how many lights I am using. 1820
Thanks for the info.
I am only using one pin. Since it is a wearable I was concerned about extra wiring and problems that can occur. I wanted to keep it simple. I am currently using the suit and don't have any problems. I thought FastLED would be better to work with. If it only takes a second or two to respond from input that would be fine.
 
Status
Not open for further replies.
Back
Top