r/FastLED • u/Ronnie_230 • Mar 17 '24
Support Help with Christmas Tree project.
Hi,
This is my first post.
Several years ago I designed a Christmas Tree using (152) WS2812B LEDs and an Adafruit Itsy Bitsy board and randomly placed the LEDs on the tree. I designed the board on PCB software and sent it out to a board house. I soldered all 152 LEDs and corresponding 152 caps along with all the other components. I am a retired Electronic Technician and PCB designer. I have no programming background but have been able to put together code (which I posted a link to) by putting together pieces of various posted codes. The tree looks good but I would like to be able to add a few features:
- Have the program start at random points in the program when the power is applied.
- Add additional led patterns (chasing, flashing, anything that would look great)
I am running Arduino 2.3.2 version.
I really appreciate any help.
Thanks in advance,
Ronnie
https://gist.github.com/RonnieVa/3eaeef202e920039aee9668bd766d1ce
2
u/Ronnie_230 May 05 '24 edited May 05 '24
Hi,
Thanks for all of your responses. I tried to update the code to solve a couple problems:
I was able to add simple pattern list and get somewhat of a random pattern but the simple patterns come up in rotation about every 10 or 12 patterns. I am trying to have the program randomly display all of my patterns in the program.
I have updated the code posted at the top to reflect the changes that I have made since the original post
Thanks for all of your help,
Please remember that I have very little programming experience.
Ronnie
2
u/sutaburosu [stavros] Mar 17 '24 edited Mar 17 '24
We can't see that link. It would be helpful to see what code you are hoping to modify.
That said, to generate a random number at cold boot you could use an ADC capable pin which is not connected to anything. There will be a small amount of random noise on a floating pin, and sampling this repeatedly can generate enough entropy to seed a PRNG. Assuming you are using FastLED's PRNG you could do something like:
2
u/chemdoc77 Mar 18 '24 edited Mar 18 '24
Hi u/Ronnie_230 - You might want to look at Jason Coon (aka u/Pup05) of Evil Genius Labs' awesome Christmas Tree V2 with code available at:
https://www.evilgeniuslabs.org/tree-v2
Edit: Also, Mark Kriegsman’s great Twinklefox sketch might be what you are looking for:
https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
with the YouTube video at:
https://www.youtube.com/watch?v=CqCaF1bD4Uk
1
u/Marmilicious [Marc Miller] Mar 18 '24
Here's a modified version of the FastLED DemoReel100 example that randomly chooses which pattern to run, and also randomly how long the pattern will run for.
https://github.com/marmilicious/FastLED_examples/blob/master/DemoReel100_random_time_and_pattern.ino
Check out our wiki for a variety of user examples you can use to build more pattern ideas with. Come back with questions as you run into coding issues.
https://www.reddit.com/r/FastLED/wiki/index/user_examples/
Cool Christmas tree project. Thank you for sharing the video.
1
u/AcidAngel_ Mar 18 '24
Hi!
How does this timingEntropy.setPeriod() function generate true randomness? Which microcontrollers does it work with?
I have been able to generate a random seed using esp_random() function on an esp32 even with no WiFi or Bluetooth on. Maybe there's one 32 bit true number in the pipeline still. I think the random number generator is used by the boot process and then shut off. You can also turn on WiFi momentarily to generate more true random numbers.
1
u/ByPr0xy Mar 21 '24
I don't know if it's the "correct" way to do it, but I would set a variable to something random (0-9 for 10 patterns for instance) when it starts and then assign each pattern to a value within the range. And then start off at the pattern the that corresponds to the random value.
If you want the pattern to change in a controlled manner then you just increment the random value by 1, if you want it random then just make a new random value (you might want to make sure the new random value isn't the same as the previous random value, otherwise the same pattern may occur twice in a row) 😀