Programming led lights for a performance

Hello! I am incredibly new to Arduino meaning I have never programmed anything with the device before. What I was wanting to do I know is going to be incredibly difficult for a first project, but I just wanted to see if it were possible before diving in.

I am a cosplayer. I have added lighting to my costumes with led strips before but only ever with battery packs and an led remote, no programming or even setup necessary at all besides plugging things in where they go- as simple as it can get.

What I was wanting to do is this:
I will be performing in a costume that lights up. I was hoping to program the lighting in the costume to go along with the music I would be dancing to. I do not want the music to be connected whatsoever to the coding or Arduino, it would be playing though a separate speaker on its own. What I was hoping to do was to start my code at the same time I pressed play on the music so that the code runs alongside the music and changes the LEDs based off of timing that goes along with different parts of the song. Is this possible?

I know that all of the lighting settings id want to use for this project are possible with the Arduino but I do not know if it is possible to run the commands for certain periods of specified time before moving on to the next setting?
For example id have the code have my LEDs display white for 13 seconds before switching to cascading rainbow for 5 seconds and so on. Is this possible with the Arduino or should I attempt this with a different piece of hardware?

Id have about an hour of music playing on a single track, so that I would only have to press play on the music once and only start the arduino once as well. If this were possible, it would be a massive amount of code most likely.

Please let me know what would work! If I am able to set code for specific times how would I go about doing so? Apologies I genuinely know nothing about coding on this thing, I know this is a big ask!

Yes, all possible with Arduino.

1 Like

But keeping it perfectly in sync with the music for an hour may be difficult.

You only need to use the built-in function millis() to achieve what you want.

Do not use only delay() because it will be almost impossible to make the timing sufficiently accurate. You can use a small number of short delay(), but the longer-term timing should always refer back to millis().

It should not be a massive amount of code. If, while you are developing the code, it begins to look like it would become massive, post the code here and ask for advice how to write the code in a smarter way.

When you prepare this music (MP3 file?) make notes about the exact times in the track that you want changes in the light patterns to happen, to a fraction of a second. Hopefully your music editing app will allow you to do that. You can then translate those times into milliseconds:

((Minutes x 60) + Seconds) x 1000

You can then compare these times to the millis() function in your code. But don't check for an exact match, because that could easily be missed. Check to see if millis() is equal to or after the desired time.

1 Like

The main reason I suspect it would be a lot of code would be due to the amount of specific settings I would want to have per song, not necessarily due to potential redundancy or unnecessarily beefy code that could be consolidated. I went ahead and mapped out my ideas for one of the songs I would be preforming during the one hour segment and it had about 40 different sections (in this I did count fading in as a section, fading out as a section, as well as staying solid or off as a section as well just to keep each step as isolated as possible, if you’d like I could provide the full light mapping example for you to read through.

For a single 4 or so minute song in the hour long setlist, coding that many changes would already be a lot of code even if I were able to consolidate it as much as possible, unless there is a shortcut I am not aware of.

At this time I only plan to program three of the songs that will be playing within the hour long track, the rest of the time the led’s would most likely just be a single solid color.

I am also considering adding buttons as an alternative to my original idea if it would be more effective. so instead of an hour long track I can just have 4 buttons- one idle button for when I’m not performing, most likely flat white led’s, and the other three for the specific programming for their respective songs. This means less room for error, but more hardware. I could see how by the end of a one hour track the delay between the programming and the audio could be substantially noticeable and ruin the effect I’d be going for.

Once I get past the planning stage and begin writing out the code (or hopefully more like editing preexisting code) for this project I will most certainly post it in this thread for peer review and feedback.

This is exactly what I have been doing so far luckily, I’m glad we’re on the same page there. in my notes I have been very exact timing wise on when specifically I want what lighting effects to happen. it should be fairly easy to convert these times into milliseconds and then into the code, hopefully

1 Like

The light mapping below is merely the first draft of many many drafts so at this time it is merely an example of how I have been working my thoughts out of my head and into the world. This was not made with coding in mind yet as I was just writing ideas for the song and what I’d like to hopefully be able to accomplish. So if it doesn’t translate easily into writing code forgive me haha. Just a brainstorm still! The timing below is unfortunately not as exact as milliseconds just yet, once I decide to go through with this project I will get more detail focused to that degree of course. That also means it’s still just timing for the singular song, I am yet to make the entire track at this time. I will most likely use this map as a guideline to base my code off of, so it is all currently just words and no commands of course. Colors codes next to dim light settings is the fully saturated rgb color, any dimming of the lights and retrieving the specific rgb code will be done later on.

Song one/ dancer #3 (red) light mapping draft one

Begin program with all lighting off

0:04-0:06.9 flat white lighting across entire led strip (unless otherwise specified assume after this point that settings would encompass entire led strip) (255,255,255)

0:07- 0:10.66 cascading/ color shift rainbow lighting

0:10.67- 0:32.59 flat white lighting (255,255,255)

0:32.60- 0:33.02 fade gradually and at an even pace from flat white to black (no lighting) so that 32.60 is fully powered white led lighting and 33.02 is powered off (no light being emitted) (unless otherwise specified assume after this point that any gradual change in lighting is at an even pace)

0:33.03- 0:35.29 fade in gradually from black to fully powered flat white lighting

0:35.3- 0:40.49 white lighting (255,255,255)

0:40.50- 1:02.69 fully powered off black LEDs

1:02.7- 1:21.46 flat red lighting (255,0,0)

1:21.47- 1:28.56 flat blue lighting (0,0,255)

1:28.57- 1:48.34 flat white lighting (255,255,255))

1:48.35- 1:49.00 gradual fade from white to no lighting

1:49.01- 1:51:00 gradual fade from no lighting (black) to flat white (255,255,255)

1:51.01- 1:56.53 flat white (255,255,255)

1:56.54- 2:04.03 dim blue lighting (0,0,255)

2:04.04- 2:11.26 dim purple lighting (160,32,240)

2:11.27-2:18.96 dim light blue lighting (143,217,251)

2:19.97- 2:25.29 dim orange lighting (255,102,0)

2:25.30- 2:29.49 dim pink lighting (255,2,141)

2:29.50- 2:33.53 fully saturated red lighting (255,0,0)

2:33.54- 2:35.26 dim yellow lighting (255,245,0)

2:35.27- 2:37.22 dim green lighting (0,255,0)

2:37.23-2:44.36 fade from black to fully powered white lighting

2:44.37- 2:46.16 no lighting

2:46.17-3:04.16 flat white lighting

3:04.17- 3:04.69 fade from fully powered white lighting to no lighting

3:04.70- 3:06.64 fade from no lighting to fully powered white lighting

3:06:65-3:11.94 fade back out to no lighting

3:11.95- 3:19.53 no lighting, black

3:19.54- 3:36.03 solid fully powered blue lighting

3:36.04- 3:52.26 solid fully powered white lighting

3:52.27-3:54.16 fully powered light blue lighting (143,217,251)

3:54.17- 3:55.83 fully powered solid blue lighting

3:55.84- 3:56.41 fully powered blue lighting fading gradually into no lighting/black

3:56.42- 3:58.19 fade from black to fully powered solid white lighting

3:58.20- 4:05.46 solid white lighting

4:05.47- 4:11.53 cascading/ color shift rainbow lighting

4:11.54- 4:13.29 no lighting

4:13.30- 4:15.08 (end of song) fade from fully saturated solid red to fully saturated solid white

4:15.09- 4:20 hold end pose and fade from fully powered solid white to no power gradually

You want a "NEXT-PREV-PAUSE/PLAY" three button controller to select the animation and when it starts. Normal operation would be sequential: PLAY... PAUSE (repeat). The "next/prev" would be if an animation was skipped by accidental pressing. You could show a LED-code representing which animation is queued.

Here is an example of one-button controlling animation functions in a simulation...

This unfortunately wouldn’t really be what I would need but I appreciate your response! I won’t be able to control the lights manually because I will be entirely focused on dancing and performing. Wrestling with my skirt and pressing buttons the entire time won’t look very good and could be quite a hassle

How about splitting the workload with an assistant. You dance and they control the timing of the lighting by remote control using a wireless link

1 Like

If you've done any kind of programming it shouldn't be too hard.

But with any kind of performance I get "nervous" because there is a hard-deadline. That's not good for something you've never done before.

Start-out simple and see how far you can go with it... Once your hardware is working and you know how to program it, adding software features is "easy" unless you run out of memory, or something like that.

You can find examples of this kind of project on the Adafruit website.

Normally in a theatrical production, the sequence might be programmed but it would be started-stopped-paused manually by someone on the lighting crew. That would require wireless communication which is another complication.

If it needs to be synchronized to the beat it gets trickier.

It's not too hard to get lights that react to the music (and there can be different lighting effects-programs for different songs, etc.) but then it's tricker to get exactly what you want, or exactly the same thing every time, especially if the sound is picked-up by a microphone. (Lights that react to the music are more common with dance lighting and not so common in stage shows.)

...There is a theatrical lighting (and effect) standard called DMX512. If this were a Broadway show, everything would be done with wireless DMX, controlled by the lighting crew. A DMX lighting device can be built with the Arduino but it's not necessary unless you are doing a big show and you already have the DMX controller, etc.

1 Like

Luckily I don’t have a set date for this project, the performance will be planned once costuming is finalized so I don’t have to worry about a deadline. The lights wouldn’t be synchronized to a beat, but would be more so changing depending on who would be singing/ certain dance moves being done or specific parts of the song like the bridge having a specific light, nothing super fancy or complex that would need the program to “hear” the music

I have seen some people on here recommend an assistant and at this point I do think that would probably be a good idea to put less stress on those performing. I don’t want anyone who is dancing to have to worry about controlling their lighting or timing a button press etc.

One of the songs would have 9 separate dancers, most of the lighting would be in sync with all 9 people but there would be some slight timing variations to create a ripple or wave effect as well as the occasional color difference between performers.

I was originally planning on handing this by having 9 separate arduinos with their individual code so that all dancers had entirely separate hardware that didn’t interact whatsoever with any other dancer. This however would me that I would have to have all of them time a button press perfectly which is basically impossible with that many people.

Is there a way I can have all 9 costumes be separate from each other but still have them connected wirelessly to each other so that I wouldn’t have to time a button press? That way maybe instead of my original idea I can just have an assistant on my computer timing everything for the performers.

I still think it would probably be best to have the timing and light sequences fully coded out since controlling 9 costumes at once that do occasionally have different lighting settings going on would be a nightmare even for an experienced person. But if it would be possible to start all 9 separate programs at the exact same time that would be miraculous.

This seems to be the only section where any complex animation is taking place. Is that correct?

Unless I missed something, all the other sections seem to be a simple fade from one colour to another, or a fixed colour.

Even that animated section could be broken down into a number of short sections, each of which is a simple colour fade.

I get the feeling that you are planning to use ws2812 led strips. Is that right? How many LEDs per costume/dancer? Or are the strips more basic RGB strips where all LEDs are the same colour?

1 Like

No. Once the pattern is established, it is only a matter of calling the pattern at the right time.

What do you mean when you say "flat" or "dim"?

Here is a link to the specific LEDs I was looking to buy:

As asked before, how many LEDs per costume will there be ?

Flat as in all of the LEDs on the costume that are being controlled would all be the same color at the same time, one flat color

Dim as in the power would be halved so that the light isn’t as bright, but every LED still being the same color.

Does that make since?

So instead of the color being at its full brightness and power it would be more dimmed