Hence you are doing two relatively simple tasks, it is possible to run those two sketches "in parallel" on one controller. However, this doesn't work like you might imagine. On a computer, it is pretty simple to run two programs at the same time, because the operating system has a so-called multi-threading. This even works on old single-core machines.
However, a single processor can NEVER do two things at a time. The whole multi-threading is a clever trick. In fact, the processor switches between both programs very fast, so for the user, it looks like both programs are running at the same time.
You need to try a similar approach. At first, you must get rid of the delay() command. This will block the processor for the given amount of time. You have to replace it with hardware or software timers. You can find a lot about hardware timers on the internet. Because I don 't think, that they are really necessary in your scenario, software timers should be much more appropriate, and they are much easier to understand.
The principle is pretty easy: Just store the time, when a part of your code should execute, in a variable. Then, enclose this code in an if statement and check, if the time is correct.
Arduino already brings a pretty simple millis() function, which gives you the milliseconds since the Arduino has been powered on. So if you want to execute a code every second (1000 milliseconds), you have to do the following steps:
- Store the current time in the head of your code (above setup and loop): unsigned long timeLastExecuted = millis();
- In your loop, check, if at least 1000 ms have passed since the last execution: if(millis() - timeLastExecuted >= 1000)
- If the if clause is true, update the timeLastExecuted variable to the current time and execute your code: timeLastExecuted = millis(); doSomeStuff();
Now, the code inside this loop will execute every 1000 ms. You can add many more timers to do more stuff after a given time. Just place all the ifs in your loop().
But you have to keep one thing in mind: With the software solution, there is no guarantee, that the code will execute exactly every 1.000000000s. It might always be off by a few ms – but it will never be shorter than 1000 ms. But if you are just turning a few LEDs on and off, it won't matter.
With this subtractive solution, you might also get a drift over time, because the delays will sum up eventually. There's also an additive solution, where you would store the time, when it should execute next instead. With that, you could just increase the timeNextExecute by 1000 each run. With that, you might still have delays for each execution, but the 1000st loop will still run after roughly 1000 seconds, and not maybe after 1000.01 ms.
However, with that additive approach, you have to keep in mind, that the millis() counter will overflow after roughly 50 days of uninterrupted operation and will reset to 0 then. However, as you are talking about a cosplay, I guess that you will power it off after a few hours.
I hope that this'll help you a little bit.