Embedding WS2811 sequences in an existing program

A friend of mine owns a “head” shop. It’s a vape shop, but he sells bongs and pipes and that kinda thing. He wanted a cabinet to display the bongs as they look when in use. The cabinet is built and I’ve about got the rest of the program working the way I want. I think the program is self explanatory, but I have NO idea how to place certain parts of the “demo reel” program into my program. I don’t want every button to trigger the same LED sequence. I’d like to have at least 3 or 4 scattered throughout. I’d also like to be able to “interupt” any given number and not have to wait on the timer to expire. I’m a PLC guy, so this is all very new to me. Any and all help with what I have written and/or the LED portion would be GREATLY appreciated. Thanks in advance. I’ve attached the file as currently written. Be gentle :slight_smile:

AdamsCabinet2.ino (5.69 KB)

I can’t read your code as mobile devices can cope with .ino files. You should have posted the code as instructed in the how to use this forum sticky post which you have no doubt read.

So what does the rest of your code do? It looks like you will have to recode the whole of your project to act as a state machine. This is where you constantly check the state of the time to see if anything needs updating. If it does you update it and then go back to looking at the time.

The updating must be done quickly and must not include the delay call.

Look for the doing several things at once as a sticky post in the programming section. See the blink without delay example code in the IDE and google state machine programming.

This is my tutorial on the topic.

For a more complex use of a state machine see the code for this project
This had to be written as a state machine because I wanted it to end the game as soon as the lid was shut.

I will reread the forum instructions and I greatly appreciate the reply. Forum etiquette has never been my strong suit. I'll check out your tutorial and go from there. Thanks again.

OK, here is how to post your code:

Having read the forum instructions, you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to insert your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE itself has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code” it can easily be quite garbled and is always more difficult to read due to the font.

It is inappropriate to attach it as a “.ino” file unless it is clearly too long (over about 9k) to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.