#define BUTTON_ONE 6
#define BUTTON_TWO 7
#define BUTTON_THREE 8
#define BUTTON_FOUR 9
#define BUTTON_FIVE 10
#define BUTTON_SIX 11
#define BUTTON_SEVEN 12
#define BUTTON_EIGHT 13

#define LED_ONE 37
#define LED_TWO 35
#define LED_THREE 33
#define LED_FOUR 31
#define LED_FIVE 29
#define LED_SIX 27
#define LED_SEVEN 25
#define LED_EIGHT 23

#define BTN_DELAY_PINONE 38
#define BTN_DELAY_PINTWO 40
#define BTN_DELAY_PINFOUR 42
#define BTN_DELAY_PINEIGHT 44
#define BTN_DELAY_PINSIXTEEN 46
#define BTN_DELAY_PINTHIRTYTWO 48
#define BTN_DELAY_PINSIXTYFOUR 50
#define BTN_DELAY_PINONETWENTYEIGHT 52

#define LED_DELAY_PINONE 53
#define LED_DELAY_PINTWO 51
#define LED_DELAY_PINFOUR 49
#define LED_DELAY_PINEIGHT 47
#define LED_DELAY_PINSIXTEEN 45
#define LED_DELAY_PINTHIRTYTWO 43
#define LED_DELAY_PINSIXTYFOUR 41
#define LED_DELAY_PINONETWENTYEIGHT 39

#define RESET_BUTTTON_ENABLE_PIN 5
#define RESET_BUTTON_PIN 4
#define RESET_BUTTON_LED 3

int buttonDelay = 2000;          // how long the other buttons are Disabled
int ledOnTime = 5000;  // how long the LED stays on for

unsigned long buttonPressed;       // time when Button is Pressed
unsigned long buttonOnePressed;    // time when Button is Pressed
unsigned long buttonTwoPressed;    // time when Button is Pressed
unsigned long buttonThreePressed;  // time when Button is Pressed
unsigned long buttonFourPressed;    // time when Button is Pressed
unsigned long buttonFivePressed;   // time when Button is Pressed
unsigned long buttonSixPressed;    // time when Button is Pressed
unsigned long buttonSevenPressed;  // time when Button is Pressed
unsigned long buttonEightPressed;  // time when Button is Pressed



void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(BUTTON_ONE, INPUT_PULLUP);
  pinMode(BUTTON_TWO, INPUT_PULLUP);
  pinMode(BUTTON_THREE, INPUT_PULLUP);
  pinMode(BUTTON_FOUR, INPUT_PULLUP);
  pinMode(BUTTON_FIVE, INPUT_PULLUP);
  pinMode(BUTTON_SIX, INPUT_PULLUP);
  pinMode(BUTTON_SEVEN, INPUT_PULLUP);
  pinMode(BUTTON_EIGHT, INPUT_PULLUP);
  pinMode(RESET_BUTTTON_ENABLE_PIN, INPUT_PULLUP);
  pinMode(RESET_BUTTON_PIN, INPUT_PULLUP);

   pinMode(BTN_DELAY_PINONE , INPUT_PULLUP);
pinMode( BTN_DELAY_PINTWO, INPUT_PULLUP);
pinMode( BTN_DELAY_PINFOUR , INPUT_PULLUP);
pinMode( BTN_DELAY_PINEIGHT , INPUT_PULLUP);
pinMode( BTN_DELAY_PINSIXTEEN , INPUT_PULLUP);
pinMode( BTN_DELAY_PINTHIRTYTWO , INPUT_PULLUP);
pinMode( BTN_DELAY_PINSIXTYFOUR , INPUT_PULLUP);
pinMode( BTN_DELAY_PINONETWENTYEIGHT, INPUT_PULLUP);

 pinMode(LED_DELAY_PINONE , INPUT_PULLUP);
pinMode( LED_DELAY_PINTWO, INPUT_PULLUP);
pinMode( LED_DELAY_PINFOUR , INPUT_PULLUP);
pinMode( LED_DELAY_PINEIGHT , INPUT_PULLUP);
pinMode( LED_DELAY_PINSIXTEEN , INPUT_PULLUP);
pinMode( LED_DELAY_PINTHIRTYTWO , INPUT_PULLUP);
pinMode( LED_DELAY_PINSIXTYFOUR , INPUT_PULLUP);
pinMode( LED_DELAY_PINONETWENTYEIGHT, INPUT_PULLUP);




  pinMode(LED_ONE, OUTPUT);
  pinMode(LED_TWO, OUTPUT);
  pinMode(LED_THREE, OUTPUT);
  pinMode(LED_FOUR, OUTPUT);
  pinMode(LED_FIVE, OUTPUT);
  pinMode(LED_SIX, OUTPUT);
  pinMode(LED_SEVEN, OUTPUT);
  pinMode(LED_EIGHT, OUTPUT);
  pinMode(RESET_BUTTON_LED, OUTPUT);

}

void loop() {

  readLedDelay();
  readBtnDelay();
  if (digitalRead(BUTTON_ONE) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {
      Serial.println("Button 1 pressed");
      digitalWrite(LED_ONE, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonOnePressed = millis();
    }
  }
  if (digitalRead(BUTTON_TWO) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {

      Serial.println("Button 2 pressed");
      digitalWrite(LED_TWO, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonTwoPressed = millis();
    }
  }
  if (digitalRead(BUTTON_THREE) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {

      Serial.println("Button 3 pressed");
      digitalWrite(LED_THREE, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonThreePressed = millis();
    }
  }
  if (digitalRead(BUTTON_FOUR) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {

      Serial.println("Button 4 pressed");
      digitalWrite(LED_FOUR, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonFourPressed = millis();
    }
  }
  if (digitalRead(BUTTON_FIVE) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {

      Serial.println("Button 5 pressed");
      digitalWrite(LED_FIVE, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonFivePressed = millis();
    }
  }
  if (digitalRead(BUTTON_SIX) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {

      Serial.println("Button 6 pressed");
      digitalWrite(LED_SIX, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonSixPressed = millis();
    }
  }
  if (digitalRead(BUTTON_SEVEN) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {

      Serial.println("Button 7 pressed");
      digitalWrite(LED_SEVEN, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonSevenPressed = millis();
    }
  }
  if (digitalRead(BUTTON_EIGHT) == 0) {
    if ((unsigned long)(millis() - buttonDelay) >= buttonPressed) {
      Serial.println("Button 8 pressed");
      digitalWrite(LED_EIGHT, HIGH);
      digitalWrite(RESET_BUTTON_LED , HIGH);
      buttonPressed = millis();
      buttonEightPressed = millis();
    }
  }
  if (digitalRead(RESET_BUTTTON_ENABLE_PIN) == 1) {
    if ((unsigned long)(millis() - ledOnTime) >= buttonOnePressed) {
      digitalWrite(LED_ONE, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonTwoPressed) {
      digitalWrite(LED_TWO, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonThreePressed) {
      digitalWrite(LED_THREE, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonFourPressed) {
      digitalWrite(LED_FOUR, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonFivePressed) {
      digitalWrite(LED_FIVE, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonSixPressed) {
      digitalWrite(LED_SIX ,LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonSevenPressed) {
      digitalWrite(LED_SEVEN, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonEightPressed) {
      digitalWrite(LED_EIGHT, LOW);
    }
    if ((unsigned long)(millis() - ledOnTime) >= buttonPressed) {
      digitalWrite(RESET_BUTTON_LED, LOW);
    }
  }
  if (digitalRead(RESET_BUTTTON_ENABLE_PIN) == 0 && digitalRead(RESET_BUTTON_PIN) == 0) {
    ledOff();
}
}

  void ledOff(){

digitalWrite(LED_ONE, LOW);
    digitalWrite(LED_TWO, LOW);
    digitalWrite(LED_THREE, LOW);
    digitalWrite(LED_FOUR, LOW);
    digitalWrite(LED_FIVE ,LOW);
    digitalWrite(LED_SIX, LOW);
    digitalWrite(LED_SEVEN, LOW);
    digitalWrite(LED_EIGHT, LOW);
    digitalWrite(RESET_BUTTON_LED , LOW);


  }


void  readBtnDelay(){

  int onTime = 0;
bool PINONE = digitalRead(BTN_DELAY_PINONE);
bool PINTWO = digitalRead(BTN_DELAY_PINTWO );
bool PINFOUR = digitalRead(BTN_DELAY_PINFOUR);
bool PINEIGHT = digitalRead(BTN_DELAY_PINEIGHT);
bool PINSIXTEEN = digitalRead(BTN_DELAY_PINSIXTEEN );
bool PINTHIRTYTWO = digitalRead(BTN_DELAY_PINTHIRTYTWO);
bool PINSIXTYFOUR = digitalRead(BTN_DELAY_PINSIXTYFOUR );
bool PINONETWENTYEIGHT = digitalRead(BTN_DELAY_PINONETWENTYEIGHT );

  if (PINONE == 0 ){onTime=onTime+1;} 
  if (PINTWO == 0 ){onTime=onTime+2;} 
  if (PINFOUR == 0 ){onTime=onTime+4;} 
  if (PINEIGHT == 0 ){onTime=onTime+8;} 
  if (PINSIXTEEN == 0 ){onTime=onTime+16; }
  if (PINTHIRTYTWO == 0 ){onTime=onTime+32;} 
  if (PINSIXTYFOUR == 0 ){onTime=onTime+64;} 
  if (PINONETWENTYEIGHT == 0 ){onTime=onTime+128;}
  //Serial.print("Button Delay time : ");
  //Serial.print(onTime);
  //Serial.println("seconds");
buttonDelay = onTime*1000;


}

void  readLedDelay(){
  int onTime = 0;
bool PINONE = digitalRead(LED_DELAY_PINONE);
bool PINTWO = digitalRead(LED_DELAY_PINTWO );
bool PINFOUR = digitalRead(LED_DELAY_PINFOUR);
bool PINEIGHT = digitalRead(LED_DELAY_PINEIGHT);
bool PINSIXTEEN = digitalRead(LED_DELAY_PINSIXTEEN );
bool PINTHIRTYTWO = digitalRead(LED_DELAY_PINTHIRTYTWO);
bool PINSIXTYFOUR = digitalRead(LED_DELAY_PINSIXTYFOUR );
bool PINONETWENTYEIGHT = digitalRead(LED_DELAY_PINONETWENTYEIGHT );

  if (PINONE == 0 ){onTime=onTime+1;} 
  if (PINTWO == 0 ){onTime=onTime+2;} 
  if (PINFOUR == 0 ){onTime=onTime+4;} 
  if (PINEIGHT == 0 ){onTime=onTime+8;} 
  if (PINSIXTEEN == 0 ){onTime=onTime+16; }
  if (PINTHIRTYTWO == 0 ){onTime=onTime+32;} 
  if (PINSIXTYFOUR == 0 ){onTime=onTime+64;} 
  if (PINONETWENTYEIGHT == 0 ){onTime=onTime+128;}
  //Serial.print("Led On time : ");
  //Serial.print(onTime);
  //Serial.println("seconds");
ledOnTime = onTime*1000;
}
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module