adjust party button

Can some one direct me how to have my “party mode” do an endless loop, until party button is pressed again? Or better yet, do an up then down sequence, then do a random sequence, loop endlessly, until party button is activated again.
Sorry about the code, but it works!

Steps_EL_wire_8_channel_skooter.ino (6.24 KB)

Skooter:
Can some one direct me how to have my "party mode" do an endless loop, until party button is pressed again? Or better yet, do an up then down sequence, then do a random sequence, loop endlessly, until party button is activated again.
Sorry about the code, but it works!

Sorry, cant seem to post my code, ...learning.... lol

Here's the code for the rest of you guys.

// Stairs , original code by Daz3nt 2013
// modified 2015 by Skooter
// Garden Steps 8 Channels , left hand side of patio
const int irup = 11;     // IR Beam at the bottom of the steps
const int irdown = 12;     // IR Beam at the top of the steps
const int partybutton = 13;     // Party button 10k res pulldown pin 13
int ch1 = 2;
int ch2 = 3;
int ch3 = 4;
int ch4 = 5;
int ch5 = 6;
int ch6 = 7;
int ch7 = 8;
int ch8 = 9;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  pinMode(ch1, OUTPUT);        // sets the digital pin as output
  pinMode(ch2, OUTPUT);      // sets the digital pin as output
  pinMode(ch3, OUTPUT);        // sets the digital pin as output
  pinMode(ch4, OUTPUT);      // sets the digital pin as output
  pinMode(ch5, OUTPUT);        // sets the digital pin as output
  pinMode(ch6, OUTPUT);      // sets the digital pin as output
  pinMode(ch7, OUTPUT);        // sets the digital pin as output
  pinMode(ch8, OUTPUT);      // sets the digital pin as output
  pinMode(irup, INPUT);       // sets the digital pin as input
  pinMode(irdown, INPUT);    // sets the digital pin as input
  pinMode(partybutton, INPUT); // sets the digital pin as input
}

void loop() {
  // read the state of the ir sensor value:
  buttonState = digitalRead(irup);
  if (buttonState == 1) {
    // turn channels on:
    
    digitalWrite(ch1, HIGH);
    delay(300);
    digitalWrite(ch2, HIGH);
    delay(300);
    digitalWrite(ch3, HIGH);
    delay(300);
    digitalWrite(ch4, HIGH);
    delay(300);
    digitalWrite(ch5, HIGH);
    delay(300);
    digitalWrite(ch6, HIGH);
    delay(300);
    digitalWrite(ch7, HIGH);
    delay(300);
    digitalWrite(ch8, HIGH);
    delay(300);
    digitalWrite(ch1, LOW);
    delay(1200);
    digitalWrite(ch2, LOW);
    delay(1100);
    digitalWrite(ch3, LOW);
    delay(1000);
    digitalWrite(ch4, LOW);
    delay(900);
    digitalWrite(ch5, LOW);
    delay(800);
    digitalWrite(ch6, LOW);
    delay(700);
    digitalWrite(ch7, LOW);
    delay(600);
    digitalWrite(ch8, LOW);
    delay(500);
  }

  // read the state of the irdown value:
  buttonState = digitalRead(irdown);
  if (buttonState == 1) {
    // turn ch on:

    digitalWrite(ch8, HIGH);
    delay(300);
    digitalWrite(ch7, HIGH);
    delay(300);
    digitalWrite(ch6, HIGH);
    delay(300);
    digitalWrite(ch5, HIGH);
    delay(300);
    digitalWrite(ch4, HIGH);
    delay(300);
    digitalWrite(ch3, HIGH);
    delay(300);
    digitalWrite(ch2, HIGH);
    delay(300);
    digitalWrite(ch1, HIGH);
    delay(300);
    digitalWrite(ch8, LOW);
    delay(1200);
    digitalWrite(ch7, LOW);
    delay(1100);
    digitalWrite(ch6, LOW);
    delay(1000);
    digitalWrite(ch5, LOW);
    delay(900);
    digitalWrite(ch4, LOW);
    delay(800);
    digitalWrite(ch3, LOW);
    delay(700);
    digitalWrite(ch2, LOW);
    delay(600);
    digitalWrite(ch1, LOW);
    delay (500);
  }

  // read the state of the partybutton value:
  buttonState = digitalRead(partybutton);
  if (buttonState == 1) {
    // turn channel on:
    
    digitalWrite(ch8, HIGH);
    delay(200);
    digitalWrite(ch8, LOW);
    delay(50);
    digitalWrite(ch7, HIGH);
    delay(200);
    digitalWrite(ch7, LOW);
    delay(50);
    digitalWrite(ch6, HIGH);
    delay(200);
    digitalWrite(ch6, LOW);
    delay(50);
    digitalWrite(ch5, HIGH);
    delay(200);
    digitalWrite(ch5, LOW);
    delay(50);
    digitalWrite(ch4, HIGH);
    delay(200);
    digitalWrite(ch4, LOW);
    delay(50);
    digitalWrite(ch3, HIGH);
    delay(200);
    digitalWrite(ch3, LOW);
    delay(50);
    digitalWrite(ch2, HIGH);
    delay(200);
    digitalWrite(ch2, LOW);
    delay(50);
    digitalWrite(ch1, HIGH);
    delay(200);
    digitalWrite(ch1, LOW);
    delay(50);
    digitalWrite(ch2, HIGH);
    delay(200);
    digitalWrite(ch2, LOW);
    delay(50);
    digitalWrite(ch3, HIGH);
    delay(200);
    digitalWrite(ch3, LOW);
    delay(50);
    digitalWrite(ch4, HIGH);
    delay(200);
    digitalWrite(ch4, LOW);
    delay(50);
    digitalWrite(ch5, HIGH);
    delay(200);
    digitalWrite(ch5, LOW);
    delay(50);
    digitalWrite(ch6, HIGH);
    delay(200);
    digitalWrite(ch6, LOW);
    delay(50);
    digitalWrite(ch7, HIGH);
    delay(200);
    digitalWrite(ch7, LOW);
    delay(50);
    digitalWrite(ch8, HIGH);
    delay(200);
    digitalWrite(ch8, LOW);
    delay(50);
    
    digitalWrite(ch1, HIGH);
    digitalWrite(ch2, HIGH);
    digitalWrite(ch3, HIGH);
    digitalWrite(ch4, HIGH);
    digitalWrite(ch5, HIGH);
    digitalWrite(ch6, HIGH);
    digitalWrite(ch7, HIGH);
    digitalWrite(ch8, HIGH);
    
    digitalWrite(ch1, LOW);
    delay(500);
    digitalWrite(ch3, LOW);
    delay(500);
    digitalWrite(ch8, LOW);
    delay(500);
    digitalWrite(ch2, LOW);
    delay(500);
    digitalWrite(ch6, LOW);
    delay(500);
    digitalWrite(ch4, LOW);
    delay(500);
    digitalWrite(ch7, LOW);
    delay(500);
    digitalWrite(ch5, LOW);
    delay(500);
  }

  // read the state of the irdown value:
  buttonState = digitalRead(irdown);
  if (buttonState == 0) {
    // turn channel off:
    
    digitalWrite(ch8, LOW);
    digitalWrite(ch7, LOW);
    digitalWrite(ch6, LOW);
    digitalWrite(ch5, LOW);
    digitalWrite(ch4, LOW);
    digitalWrite(ch3, LOW);
    digitalWrite(ch2, LOW);
    digitalWrite(ch1, LOW);
  }

  // read the state of the partybutton value:
  buttonState = digitalRead(partybutton);
  if (buttonState == 0) {
    // turn channels off:
    
    digitalWrite(ch8, LOW);
    digitalWrite(ch7, LOW);
    digitalWrite(ch6, LOW);
    digitalWrite(ch5, LOW);
    digitalWrite(ch4, LOW);
    digitalWrite(ch3, LOW);
    digitalWrite(ch2, LOW);
    digitalWrite(ch1, LOW);
  }

  // read the state of the pushbutton value:
  buttonState = digitalRead(irup);
  if (buttonState == 0) {
    // turn channel off:
    
    digitalWrite(ch8, LOW);
    digitalWrite(ch7, LOW);
    digitalWrite(ch6, LOW);
    digitalWrite(ch5, LOW);
    digitalWrite(ch4, LOW);
    digitalWrite(ch3, LOW);
    digitalWrite(ch2, LOW);
    digitalWrite(ch1, LOW);
  }
  else {
    // turn channel off:
    digitalWrite(ch1, LOW);
    digitalWrite(ch2, LOW);
    digitalWrite(ch3, LOW);
    digitalWrite(ch4, LOW);
    digitalWrite(ch5, LOW);
    digitalWrite(ch6, LOW);
    digitalWrite(ch7, LOW);
    digitalWrite(ch8, LOW);

  }
}

With all those delays, it's not going to be very responsive, is it?

Implement it as a state machine, so you can remove all the delays.

AWOL:
With all those delays, it's not going to be very responsive, is it?

Implement it as a state machine, so you can remove all the delays.

The delays prevent excessive triggering of PIRs ... works like a charm, for my first project, the el wire steps work great. Just wondering how to do the party loop

Just wondering how to do the party loop

You have been told, you need to remove the delays and implement a state machine. The fact that it works with delay is what is stopping you making your party button from working.

Grumpy_Mike:
You have been told, you need to remove the delays and implement a state machine. The fact that it works with delay is what is stopping you making your party button from working.

... ok ...so, as I did apologize in advance for my code, can you explain a bit more? How to remove the delays, and why it would interfere with the party mode? Can I leave the delays in the irup and ir down loops and just change the party loop? What will prevent the irup and down PIRs from being tripped if more than one person is on the steps? Again thanks for the help

If you use a state machint type of programming style, you can look at your end button many times a second. You also then go and do the next step in your sequence. That is the over view, for more detail see:-

http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html
Or Robin2's several things at once

Skooter:
How to remove the delays, and why it would interfere with the party mode?

grumpy_mike gave you some good links on how to remove delay, here's another;

the reason why it interferes is the same reason it stops the PIR's from triggering
because delay tells your program to stop doing pretty much anything (like reading your party button)
till the delay is over.

if you press the button during a delay nothing will happen

Hutkikz:
grumpy_mike gave you some good links on how to remove delay, here's another;

http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay

the reason why it interferes is the same reason it stops the PIR's from triggering
because delay tells your program to stop doing pretty much anything (like reading your party button)
till the delay is over.

if you press the button during a delay nothing will happen

[/quote
] Thank you, oh well my first try has at least impressed my neighbours. I just thought I would use the KISS method. This will do for the nonce.