Compiling codes in one.

So a month ago I started playing with arduino UNO and RGB WS2812B leds but I’m bad in coding (hope temporary).
Found some codes with I liked and I want to put them in to the one and switch them between with button.
I want to make a gift for a friend, he has oldschool car and upgrade interior lighting.
But I have less than 2 weeks for that and no time for serious code learning.
Maybe somebody can help me with that?
I’m attaching codes and want to put them all in 3modes.ino
I would highly appreciate any help, or donate for a beer or something if needed. :slight_smile:

3modes.ino (5.84 KB)

Knight_Raider_Rainbow.ino (3.6 KB)

Knight_Raider_Red.ino (2.09 KB)

Police.ino (1.79 KB)

Hi there!

This sounds like a very interesting project.

I took all of your codes and combined them into your 3codes.ino file, which I have attached. Basically, I added a button debounce feature that allows a button to cycle through the three modes. I then took each of the three mode codes and placed them in function in the main code. I modified your switch statement by commenting out what function calls you had and put in the function calls for the three modes. I compiled the code on my computer and got no errors, but since I don’t have the library you are using nor do I have an LED array that you are using, I cannot test if my code works. Try running it on your board and see what happens.

I believe you have the button set up so that is connects the digital pin on the Arduino to ground, since you call the pinMode(pin, INPUT_PULLUP); command in your setup function. Assuming this is correct, then the button pressing should work.

Let me know what happens!

3modes.ino (10.5 KB)

Hi Bos1714,

Didn't expected so fast reply.. :slight_smile: Thanks for it!

Yes I have button, 3modes was working fine.
Yours edit starts with knight_rider_rainbow and button not switching.. :confused:

By me self I was added police in "case 4:" but I was missing some code part.. so I was able to turn it but after few blinks it stuck..

Ok, I played a bit with it…

Mixed what bos1714 made for me wit 3modes, and I made one 6_modes.

Now I’m able to switch them all but those 3 codes witch I added not changing immediately, after pressing button. Only when their cycle is ended I’m able to change to next mode.

Firs 3 modes can be switched any time…

6_modes.ino (10.6 KB)