MultiStrobProject - Stuck need help with for loops ect.

So I'm a complete noob. This is only my second day of coding - I whipped this up on my first day.

/*Code for strobe that ustalises multiple LED strips
   Different sequences can be decided with combonations of switches
   Cycle speed can be determined manually with potentiometer
   Or automatically with and audio input
 
 *Each strip is run via a relay - These relays are connected to digital outputs
 
 *1 cycle = 1 led strip - LOW > HIGH > LOW
 
 *There are 4 switch inputs and 2 potentiometer inputs
 
   3 of the 4 switch inputs create different strobe sequences in different combination
   1 of the 4 switch inputs determines whether sequence cycle speed is set manually via potentiometer 
                                                                    or automatically via audio input
 
   Manual control = time for 1 cycle is determined manually with a potentiometer 
   Automatic control = 1 cycle is induced everytime the audio crosses the threshold set by a potentiometer
                                                    
   1 potentiometer maunually controls the time each cycle will take in a sequence
   1 potentiometer will set the threshold for the audio to induce an autocycle
 */
 
//LED strip outputs digitalPins 0-7

int stripPin1 = 0;
int stripPin2 = 1;
int stripPin3 = 2;
int stripPin4 = 3;
int stripPin5 = 4;
int stripPin6 = 5;
int stripPin7 = 6;
int stripPin8 = 7;

//switch pin inputs digitalPins 8-11

int switchPin1 = 8;
int switchPin2 = 9;
int switchPin3 = 10;
int switchPin4 = 11;

//potentiometers inputs analogPins A0-1

//manual control
int potPin1 = A0;

//auto control
int potPin2 = A1;

//audio input analogPin A2

int AUXpin = A2;


void setup() {
  
//setting all LED strips as outputs

for (int outputPin = 0; outputPin < 8; outputPin++){
  pinMode(outputPin, OUTPUT);
}

//setting all switches as inputs

for (int inputPin = 8; inputPin < 12; inputPin++){
  pinMode(inputPin, INPUT);
}

//setting potentiometers as inputs

pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);

//setting audio as input

pinMode(AUXpin, INPUT);
}


void loop() {
/*Cycle speed setting manual/automatic
  This is in order to determine whether strobe sequences cycle at a speed determined by audio
  Or at a speed set manually
 */

//Determining audio input level
int audioInput = analogRead(AUXpin);
  
//Determing potentiometer inputs

//This will = the time for each manual cycle
int manualCycle = analogRead(potPin1);

//This will = the threshold the audio input must cross to induce a cycle
int audioThreshold = analogRead(potPin2);

/*Determing if audio input will induce a single auto cycle 
  (auto cycle will take place regardless of audio input level every 2 seconds) */
  
int autoCycle = 2000;
if (audioInput > audioThreshold){
 autoCycle = 10;
}

//Determining whether delay time (time for each cycle) = manual or auto cycle

int autoActivate = digitalRead(switchPin4);

int delayTime = manualCycle;  

if (autoActivate, HIGH){
 delayTime = autoCycle;
} 

/*Determining sequence pattern
  This section is to determine which sequence the strobe follows
  There are 3 input switches = 8 sequences

  3 Switches   = S1, S2, S3
  8 LED strips = 1, 2, 3, 4, 5,6, 7, 8

  Sequence 1 = S1 LOW,  S2 LOW,  S3 LOW  = All strips strobe
  Sequence 2 = S1 HIGH, S2 LOW,  S3 LOW  = Strips sequence 1>2>3>4>5>6>7>8 REPEAT
  Sequence 3 = S1 LOW,  S2 HIGH, S3 LOW  = Strips sequence 8>7>6>5>4>3>2>1 REPEAT 
  Sequence 4 = S1 LOW,  S2 LOW,  S3 HIGH = Strips sequence 1>2>3>4>5>6>7>8>7>6>5>4>3>2 REPEAT
  Sequence 5 = S1 HIGH, S2 HIGH, S3 LOW  = Strips sequence 1>8>2>7>3>6>4>5>4>6>3>7>2>8 REPEAT
  Sequence 6 = S1 HIGH, S2 LOW,  S3 HIGH = Strips sequence 1,8>2,7>3,6>4,5>3,6>7,2 REPEAT
  Sequence 7 = S1 LOW,  S2 HIGH, S3 HIGH = Strips sequence 1>3>2>4>3>5>4>6>5>7>6>8>7>8>6>7>5>6>4>5>3>4>2>3>1>2 REPEAT
  Sequence 8 = S1 HIGH, S2 HIGH, S3 HIGH = RANDOM sequence ?>? REPEAT
 */
}

I'm throwing a party and I wanted to create a strobe system that uses led strips that are on the ceiling of the room, from the front to the back. I have an led driver and relays to allow for the arduino to control the strips. I then want to have the strips play different sequences and different speeds. I want there to be 2 speed settings.
Manual speed - set with a potentiometer
Automatic speed - determined by the music being played + a potentiometer to set a threshold

The sequence being used is then determined with 3 switches in different combinations. This gives a total of 8 sequences I think? I would've thought 9, but I could only find 8 lol

I've written the first part of the code to determine whether the strobe speed is controlled automatically or manually - if you could check that code that'd be great

Now all I need to do is program the sequences. I've written the in the code the different sequences I want the strips to follow. What would be your opinion of the best way to program these sequences and to program the switch inputs that determine them? Should I use If functions to determine the sequences? and Should I use arrays to program the sequence?

I hope this all makes sense. I try to explain the code as best i can in comments.

Thanks in advance for the help,

Aikju :slight_smile:

I've since added to this code - I've used for loops to do sequences 1, 2 and 3.
However, I do not know how to do the rest - Please help haha

/*Code for strobe that ustalises multiple LED strips
   Different sequences can be decided with combonations of switches
   Cycle speed can be determined manually with potentiometer
   Or automatically with and audio input
 
 *Each strip is run via a relay - These relays are connected to digital outputs
 
 *1 cycle = 1 led strip - LOW > HIGH > LOW
 
 *There are 4 switch inputs and 2 potentiometer inputs
 
   3 of the 4 switch inputs create different strobe sequences in different combination
   1 of the 4 switch inputs determines whether sequence cycle speed is set manually via potentiometer 
                                                                    or automatically via audio input
 
   Manual control = time for 1 cycle is determined manually with a potentiometer 
   Automatic control = 1 cycle is induced everytime the audio crosses the threshold set by a potentiometer
                                                    
   1 potentiometer maunually controls the time each cycle will take in a sequence
   1 potentiometer will set the threshold for the audio to induce an autocycle
 */
 
//LED strip outputs digitalPins 0-7

int ledArray[]{
0, 1, 2, 3, 4, 5, 6, 7  
};

//switch pin inputs digitalPins 8-11

int switchPin1 = 8;
int switchPin2 = 9;
int switchPin3 = 10;
int switchPin4 = 11;

//potentiometers inputs analogPins A0-1

//manual control
int potPin1 = A0;

//auto control
int potPin2 = A1;

//audio input analogPin A2

int AUXpin = A2;


void setup() {
  
//setting all LED strips as outputs

for (int outputPin = 0; outputPin < 8; outputPin++){
  pinMode(outputPin, OUTPUT);
}

//setting all switches as inputs

for (int inputPin = 8; inputPin < 12; inputPin++){
  pinMode(inputPin, INPUT);
}

//setting potentiometers as inputs

pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);

//setting audio as input

pinMode(AUXpin, INPUT);
}


void loop() {
/*Cycle speed setting manual/automatic
  This is in order to determine whether strobe sequences cycle at a speed determined by audio
  Or at a speed set manually
 */

//Determining audio input level
int audioInput = analogRead(AUXpin);
  
//Determing potentiometer inputs

//This will = the time for each manual cycle
int manualCycle = analogRead(potPin1);

//This will = the threshold the audio input must cross to induce a cycle
int audioThreshold = analogRead(potPin2);

/*Determing if audio input will induce a single auto cycle 
  (auto cycle will take place regardless of audio input level every 2 seconds) */
  
int autoCycle = 2000;
if (audioInput > audioThreshold){
 autoCycle = 10;
}

//Determining whether delay time (time for each cycle) = manual or auto cycle

int autoActivate = digitalRead(switchPin4);

int delayTime = manualCycle;  

if (autoActivate, HIGH){
 delayTime = autoCycle;
} 

/*Determining sequence pattern
  This section is to determine which sequence the strobe follows
  There are 3 input switches = 8 sequences

  3 Switches   = S1, S2, S3
  8 LED strips = 1, 2, 3, 4, 5,6, 7, 8

  Sequence 1 = S1 LOW,  S2 LOW,  S3 LOW  = All strips strobe
  Sequence 2 = S1 HIGH, S2 LOW,  S3 LOW  = Strips sequence 1>2>3>4>5>6>7>8 REPEAT
  Sequence 3 = S1 LOW,  S2 HIGH, S3 LOW  = Strips sequence 8>7>6>5>4>3>2>1 REPEAT 
  Sequence 4 = S1 LOW,  S2 LOW,  S3 HIGH = Strips sequence 1>2>3>4>5>6>7>8>7>6>5>4>3>2 REPEAT
  Sequence 5 = S1 HIGH, S2 HIGH, S3 LOW  = Strips sequence 1>8>2>7>3>6>4>5>4>6>3>7>2>8 REPEAT
  Sequence 6 = S1 HIGH, S2 LOW,  S3 HIGH = Strips sequence 1,8>2,7>3,6>4,5>3,6>7,2 REPEAT
  Sequence 7 = S1 LOW,  S2 HIGH, S3 HIGH = Strips sequence 1>3>2>4>3>5>4>6>5>7>6>8>7>8>6>7>5>6>4>5>3>4>2>3>1>2 REPEAT
  Sequence 8 = S1 HIGH, S2 HIGH, S3 HIGH = RANDOM sequence ?>? REPEAT
 */

//determing switch combination

int switch1 = digitalRead(switchPin1);
int switch2 = digitalRead(switchPin2);
int switch3 = digitalRead(switchPin2);

//sequence booleans


//Setting all LEDs to LOW

delay(delayTime)
for (int actStrip = 0; actStrip < 8; actStrip++) {
digitalWrite(ledArray[actStrip], LOW);
}

//Sequence 1

if (switch1 == LOW && switch2 == LOW && switch3 == LOW) {
  delay(delayTime)
  for (int actStrip = 0; actStrip < 8; actStrip++)
  digitalWrite(ledArray[actStrip], HIGH);
}

//Sequence 2

if (switch1 == HIGH && switch2 == LOW && switch3 == LOW) {
  for (int actStrip = 0; actStrip < 8; delay(delayTime); actStrip++)
  digitalWrite(ledArray[actStrip], HIGH);
}

//Sequence 3

if (switch1 == LOW && switch2 == HIGH && switch3 == LOW) {
  for (int actStrip = 8; actStrip > -1; delay(delayTime); actStrip--)
  digitalWrite(ledArray[actStrip], HIGH);
}
}
//Determining audio input level
int audioInput = analogRead(AUXpin);

Whether that comment is true, or complete rubbish, depends on exactly what is connected to that pin. So, what is connected to the pin?

int switchPin1 = 8;
int switchPin2 = 9;
int switchPin3 = 10;
int switchPin4 = 11;

So, you have a box with 4 switches, numbered 1, 2, 3, and 4, with no clue what they do. Makes no sense to me.

int switch1 = digitalRead(switchPin1);
int switch2 = digitalRead(switchPin2);
int switch3 = digitalRead(switchPin2);

So, the third state variable is valued by reading the second switch. I see...

You, know, when I discovered that you posted code that won't even compile, I quit reading.

PaulS:

//Determining audio input level

int audioInput = analogRead(AUXpin);



Whether that comment is true, or complete rubbish, depends on exactly what is connected to that pin. So, what is connected to the pin?
So, you have a box with 4 switches, numbered 1, 2, 3, and 4, with no clue what they do. Makes no sense to me.



int switch1 = digitalRead(switchPin1);
int switch2 = digitalRead(switchPin2);
int switch3 = digitalRead(switchPin2);



So, the third state variable is valued by reading the second switch. I see...

You, know, when I discovered that you posted code that won't even compile, I quit reading.

Dude, literally said I started yesterday - cut me some slack. You didn't even try to answer my question. So, thanks.

But you are right. I will try and improve my comments and alter the code so it compiles properly - which for the record I tested before posting.

which for the record I tested before posting.

You must have tested some code other than what you posted.

You are missing a ; on the delay() call.

if (switch1 == LOW && switch2 == LOW && switch3 == LOW) {
  delay(delayTime)
  for (int actStrip = 0; actStrip < 8; actStrip++)

PaulS:
You must have tested some code other than what you posted.

You are missing a ; on the delay() call.

if (switch1 == LOW && switch2 == LOW && switch3 == LOW) {

delay(delayTime)
  for (int actStrip = 0; actStrip < 8; actStrip++)

Nice 1 paul