Firefly wig - need help with coding PWM, randomization, and more

Hey, I’m a newbie and I need coding help!

I’ve got a project in mind I’m trying to write code for. Basically, I’m trying to put one individually-addressable pixel onto each port of a Pro Trinket and:

1— Make them fade in and out naturally, like fireflies, being able to randomize the flash speed and max brightness of each flash of each pixel between certain parameters. (I want the “fireflies” to look as natural and biological as possible to someone watching.)

2— Have a few other flash patterns (like a heartbeat) and different colors. I’m okay with having a number of programmed pattern+color pre-sets that I can just choose with the control pad I make. (I will probably assign the presets to a potentiometer switch.)

3— When switching to a new preset with the potentiometer switch, I want the code to wait to execute until the switch is on a new preset for a whole second, so that, for example, I wouldn’t start the codes for 5 different presets just trying to move 5 spots down. (I don’t know how important that is, but it seems like good practice for a switch that will change as often as this one will.)

4— Have all color and pattern changes (including turning the whole thing on and off) shift slowly over the course of maybe 5 or 10 seconds, so it never looks like an electronic switch. (Fun optional bonus: have each light change to the next preset color+pattern at a slightly different, randomized rate.)

5— Control the brightness of the whole thing all at once, and the speed of the flash pattern of the whole thing all at once, probably also through potentiometer switches on my control pad.

I’ve been advised that the best way to get the light fading effect I want is PWM, but I haven’t gotten to the point where I grok what that means for coding.

—Design stuff:—

This project is going to be a wig that looks like there are fireflies in it. I intend to put the pixels on long strands that I can disperse easily through the wig. I haven’t quite figured out how I’m going to conceal the wires yet - maybe clear heat-shrink that I’ll paint to blend in with the wig?

For the control pad: it needs to be small, and WIRED - I need to not have to point a wireless remote at a certain spot, because this is for a theatrical thing and I need to be able to change the lights subtly on the fly. I want the control pad on a wire long enough to run down my sleeve or the inside of my clothes so I can access it easily. It also would be great if it was as small and flat as possible, but a higher priority is to find potentiometer switches that can be operated with one hand. (I might be asking for a lot here, but I really just don’t know a lot about what’s out there. I might make a separate post about designing and building the control pad, but if you have any advice to offer now, I’m all ears.)

Here are the products I’m using:
Adafruit Pro Trinket - Adafruit Pro Trinket - 5V 16MHz : ID 2000 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
These pixels - https://www.amazon.com/gp/product/B01DC0J3UM/
This FTDI breakout board that was recommended to me - https://www.amazon.com/gp/product/B0068QKQEA/

I’ve attached a picture of approximately what it should look like. Those are fairy lights on copper wire, which are beautiful but not very customizable (and very uncooperative in wigs).

What are you going to start on FIRST? Then perhaps we can help.

Paul

PWM is no good for individual addressable pixels you need a library to drive them like the Adafruit one or the fastLED library.

We do not write code for you we help you get it right. Start simply and build it up in very small steps. Start with the examples you find with the library you want to use, even though it will probably not do what you want it is useful to check the hardware is working.

Rather than have one LED per line it is simpler to have a string of them.

Please post pictures inline instead of downloading - see sticky in the forum.

SmithGMH:
This project is going to be a wig that looks like there are fireflies in it.
db2081ee46b04975e30f8e4ec42f42ffda6a1a2f.jpg

Fireflies in that wig? Well, that’s not going to look very natural, unless your part of the world has very very different fireflies than where I live (I’ve been operating fireflies watching tours for four seasons now, so I’ve got a quite good idea how the little critters look like). They normally like to hang from trees near water.

They don’t fade in and out, they flash, very fast, so fast that you can barely make out the individual flashes.

The light is a yellowish green, quite different from the standard yellow and green LED colours, for all >2000 species in the world that’s the same. Some species will flash constantly, others flash in bursts of a few seconds, and are then dark for some time (the ones that I’ve seen are dark about twice as long as the flashing burst). To mimic their colour you will need RGB LEDs and finely tune it.

The most natural will be a bunch of LEDs randomly strung through that wig, each flashing independently. It’ll be quite noticeable if they all flash perfectly in sync, even at the high frequency of a few flashes a second (the flash frequency should be the same of all of them - each species has a specific flash).