unsigned long pre1 =0;
unsigned long pre2 =0;
unsigned long pre3 =0;
unsigned long pre4 =0;

unsigned long timer1 =0;
unsigned long timer2 =0;
unsigned long timer3 =0;
unsigned long timer4 =0;

unsigned long current1 =0;
unsigned long current2 =0;
unsigned long current3 =0;
unsigned long current4 =0;

int led1 = 1;
int led2 = 1;
int led3 = 1;
int led4 = 1;

int state =0;


void setup() {
  Serial.begin(115200);      
  
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(2, INPUT_PULLUP);
//attachInterrupt(digitalPinToInterrupt(2), blink, CHANGE);
  attachInterrupt( 0,blink,CHANGE);//interrupt
}////////////////////////////////////

void loop() {
  current1 = millis();

if (current1 - pre1 >= timer1) { /////////////led1
      Serial.println(pre1);
      pre1 = current1;

    if (led1 == LOW) {
      led1 = HIGH;
    } else {
      led1 = LOW;
    }
    digitalWrite(13, led1);
  }
  if (current2 - pre2 >= timer2) { //////////////led2
      Serial.println(pre2);
      pre2 = current2;

    if (led2 == LOW) {
      led2 = HIGH;
    } else {
      led2 = LOW;
    }
    digitalWrite(12, led2);
  }
  if (current3 - pre3 >= timer3) { ///////////3
      Serial.println(pre3);
      pre3 = current3;

    if (led3 == LOW) {
      led3 = HIGH;
    } else {
      led3 = LOW;
    }
    digitalWrite(11, led3);

    if (current4 - pre4 >= timer4) {/////////////led4
      Serial.println(pre4);
      pre4 = current4;

    if (led4 == LOW) {
      led4 = HIGH;
    } else {
      led4 = LOW;
    }
    digitalWrite(10, led4);
  }
  digitalWrite(8, state);
  
}///////////endloop
void blink(){
  if (state == 0){
    state = 1;
}
else{
    state =0;
}
}

/*void blink () {//////por
  /*if (state == 0){
   state = 1; 
  }else {
  state = 0;*/
   state = !state;
}*/





/*if (current1 - pre1 >= timer1) {
      Serial.println(pre1);
      pre1 = current1;

    if (led1 == LOW) {
      led1 = HIGH;
    } else {
      led1 = LOW;
    }
    digitalWrite(13, led1);
  }*/