const int led[]={8,9};
const int button[]={5,2};
int ledState=LOW;
int buttonpushcounter=0;
int buttonstate=0;
int lastbuttonstate=0;
long previousMillis=0;
long interval=1000;
void setup(){
for(int i=0;i<2;i++){
pinMode(led[i],OUTPUT);
pinMode(button[i],INPUT);
Serial.begin(9600);
}
}
void loop(){
//ciclo Blink-ledState
for(int i=0;i<2;i++){
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// salva l'ultima volta che il led si è acceso
previousMillis = currentMillis;
// se il led è acceso e vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
buttonstate=digitalRead(button[i]);
//se il bottone viene premuto aumenta il counter
if(buttonstate !=lastbuttonstate){
if (buttonstate=HIGH){
buttonpushcounter++;
}
else{
}
}
lastbuttonstate=buttonstate;
if(buttonpushcounter %1==0){
digitalWrite(led[i],ledState);
}
else{
digitalWrite(led[i],LOW);
}
}
}
}
So basically i tryed to put togheter the blinking code and counter also.. I dont have time to check if it's working or not. I tryed to listen to all of you suggestion.. the only problem is with the debounce code. i don't know where to set it. Thanks again for help guys !