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
}
}