const int TASTER = 3;
const byte pinTaster[] = {3, 4, 5};
int counter[] = {0,0,0};
int merkerTaster[] = {0,1,2};
int statusTaster[] = {0,1,2};
int tmpdata[] = {0,1,2};
int schalter(int pin) {
statusTaster[pin] = !digitalRead(pinTaster[pin]);
delay(10);
if (statusTaster[pin] & !merkerTaster[pin]) {
merkerTaster[pin] = true;
counter[pin] ++;
Serial.print((String)"Taste_"+pin+":\t");
Serial.println(counter[pin]);
}
if (!statusTaster[pin]) {
merkerTaster[pin] = false;
}
return counter[pin];
}
void setup() {
Serial.begin(9600);
pinMode(pinTaster[0], INPUT_PULLUP);
pinMode(pinTaster[1], INPUT_PULLUP);
pinMode(pinTaster[2], INPUT_PULLUP);
}
void loop() {
tmpdata[0] = schalter(0);
tmpdata[1] = schalter(1);
tmpdata[2] = schalter(2);
if(tmpdata[0] != 0) {
if(tmpdata[0] == tmpdata[1]) {
counter[0] = 0;
counter[1] = 0;
Serial.println("Pin 1 & 2 Reset");
}
}
}