Arduino and dip switches

Hi there everyone

I really need some guidance with a project I'm busy with. I am constructing a LED light strip driver using a Nano(V3.0) and a ULN2003 driver. My current code works perfectly, but I need to add a pair of dip switches to cancel the last 2 LED strips.

The idea behind it is this: Power on, LED strip 1 starts, followed by LED strip 2, then LED strip 3, etc. As the next strip comes on the first switches off, eventually starting back at number 1.

I need to add 2 dip switches onto LED strip 4 and 5, to turn them on and off, but at the same time turning their respective timing on and off as well.

So basically, if 4 and 5 are off, the sequence runs 1, 2, 3, 1, 2, 3.... with their timing inbetween.

Am I making sense?

Read the DIP switch states and if they are off skip sequences 4 and 5.
If you had posted your code it would be easier to give more definitive advice.

// the setup function runs once when you press reset or power the board
void setup() {

pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);

}

void loop() {

digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
delay(1000);

digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
delay(960);

digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
delay(600);

digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
delay(960);

digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
delay(600);

digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
delay(960);

digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
delay(600);

digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
delay(960);

}

So, if the DIP switches are open you want to skip the last 2 sets of digitalWrite()s Is that correct ?

Do you know how to read the DIP switches ? How are they wired ?

UKHeliBob:
So, if the DIP switches are open you want to skip the last 2 sets of digitalWrite()s Is that correct ?

Do you know how to read the DIP switches ? How are they wired ?

I would prefer the dip switches to be closed to skip the last two steps, but I'm not too phased. With regards to reading DIP switches, I read a few examples of Pull up methods. At the moment they are wired in a pull up method. 5v and Pin(#) on one side of the dipswitch, GND on the other

Open or closed to skip makes no real difference but in your OP you said

if 4 and 5 are off, the sequence runs 1, 2, 3, 1, 2, 3.

and I took that to mean open.

I am not clear how you have the switches wired.

The easiest way to wire them is one switch contact to GND, the other to a pin and using pinMode(pinNumber, INPUT_PULLUP); to ensure that the pin is in a known state. This requires no external resistors and is easy to wire up.

Can you read the pin state with a simple Arduino program ?
Do both DIP switches need to be in a particular state to skip the last 2 sequences or does each of them control one sequence ? Would it be OK if both sequences were skipped by the position of a single switch ?

UKHeliBob:
Can you read the pin state with a simple Arduino program ?

Yes

UKHeliBob:
Do both DIP switches need to be in a particular state to skip the last 2 sequences or does each of them control one sequence ?

Yes

UKHeliBob:
Would it be OK if both sequences were skipped by the position of a single switch ?

No

So, assuming that the DIP switches are wired as I suggested and named dip1 and dip2 then

if (dip1 == LOW && dip2 == LOW) //both DIP switches closed
  {
    //do stuff with LED strips 3 and 4
  }

Adjust the HIGH/LOW logic to suit your requirements