LED startup sequence question

This is for a model starship. My startup sequence is as such.

4 leds blink on and off a few times then stay on with a slight fade in and out.
Once the slight fade in and out begins I have 3 leds that randomly blink on and off and a pair of leds that
blink rhythmically turn on.

My code isn't good but it's functional and I have the leds doing what I want them to do in the order that I like.

My problem is that I would like to add an IR remote to turn on the entire sequence but my code is making it difficult. Ideally I would press one button to initiate the sequence and hit the same one again to turn it off. I can't piece together enough mostly unrelated tutorials to accomplish this and i have no programming knowledge. I'm at whits end so hopefully someone can help. Thank you.

Here is my code.

const int LED1 = 5;
const int LED2 = 9;
const int LED3 = 10;
const int LED4= 3;

int led1 = 5;
int led2 = 9;
int led3 = 10;
int led4 = 3;

int ledPin5 = 2;
int ledPin6 = 4;
int ledPin7 = 13;

int led8 = 12;

void setup() {
pinMode (5, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (3, OUTPUT);

pinMode (12, OUTPUT);

digitalWrite (5, HIGH);
digitalWrite (9, HIGH);
digitalWrite (10, HIGH);
digitalWrite (3, HIGH);

delay (100);

digitalWrite (5, LOW);
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (3, LOW);

delay (200);

digitalWrite (5, HIGH);
digitalWrite (9, HIGH);
digitalWrite (10, HIGH);
digitalWrite (3, HIGH);

delay (100);

digitalWrite (5, LOW);
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (3, LOW);

delay (100);

digitalWrite (5, HIGH);
digitalWrite (9, HIGH);
digitalWrite (10, HIGH);
digitalWrite (3, HIGH);

delay (100);

digitalWrite (5, LOW);
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (3, LOW);

delay (300);

digitalWrite (5, HIGH);
digitalWrite (9, HIGH);
digitalWrite (10, HIGH);
digitalWrite (3, HIGH);

delay (300);

digitalWrite (5, LOW);
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (3, LOW);

delay (700);

digitalWrite (5, HIGH);
digitalWrite (9, HIGH);
digitalWrite (10, HIGH);
digitalWrite (3, HIGH);

}

void loop() {

float in, out;

for (in = 0; in < 0.541; in = in + 0.001)
{
out = sin(in) * 127.5 + 127.5;

analogWrite(LED1,out);
analogWrite(LED2,out);
analogWrite(LED3,out);
analogWrite(LED4,out);
}
{analogWrite(ledPin5, random(100, 200));
delay(random(105));
analogWrite(ledPin6, random(100, 200));
delay(random(115));
analogWrite(ledPin7, random(100, 200 ));
delay(random(110));
}
{
digitalWrite(led8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led8, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
}

Forget your main project for now.

Have you managed to use the IR control to do something simple such as turning on an LED or output a message to Serial ??

#1 post the code in code tags or you will get yapped at by the big boys. See above looks like "</>".

#2 Probably going to have to change your thinking from a long list, to something without delay()s. Think groups of lights running in their own sections of code not interfering with everything else that will be running at the same time.

If you can code one group to do its thing without delay()s. Then you can do them all and in your loop() just call each one to give it time to check things.

Once you have it running like that the ID will probably be pretty easy.

Good luck, hope this helps.

-jim lee

UKHeliBob:
Forget your main project for now.

Have you managed to use the IR control to do something simple such as turning on an LED or output a message to Serial ??

Yes I experimented by using the ir remote to control the code of my initial 4 leds that blink then fade in and out.

jimLee:
If you can code one group to do its thing without delay()s. Then you can do them all and in your loop() just call each one to give it time to check things.

Once you have it running like that the ID will probably be pretty easy.

Good luck, hope this helps.

-jim lee

I tried to research that but I can't figure out a code to stop the sequence for my initial 4 leds. They blink a few times then fade in and out until power is removed.

You will need to get the code written without using delays() or you won't be able to add in the IR code at all easily.

You may want to look at my MultiBlink sketch (or even use it as a base) for how to get the LEDs done in a data driven approach - link in my signature block below. Modify this code to use switches to change from one LED sequence to another - from memory there is already an example on how you could do this.

I would recommend the IRLib library for the IR portion, as that is what I use. Start by running the example programs to make sure your IR control hardware is working ok. The incorporate the IR in the code and use it to trigger the changes instead of the switches.

At all times make sure you are building on something that works before you move on to add a new feature/mode. This will help greatly with the debugging.