int button_groen = 22; //teller1 ++
int button_blauw = 21; //teller2 ++
int button_geel = 19; // teller 1 => 0
int button_rood = 18; // teller 2 => 0
void setup() {
Serial.begin(115200);
pinMode(button_groen, INPUT_PULLUP);
pinMode(button_blauw, INPUT_PULLUP);
pinMode(button_geel, INPUT_PULLUP);
pinMode(button_rood, INPUT_PULLUP);
}
void loop() {
static bool status_groen_eerder = 1;
static bool status_blauw_eerder = 1;
static bool status_geel_eerder = 1;
static bool status_rood_eerder = 1;
static int teller1 = 0;
static int teller2 = 0;
bool status_groen = digitalRead(button_groen);
bool status_blauw = digitalRead(button_blauw);
bool status_geel = digitalRead(button_geel);
bool status_rood = digitalRead(button_rood);
if (status_groen != status_groen_eerder) {
status_groen_eerder = status_groen;
if (status_groen == 0) {
teller1 ++;
teller2 = 0;
Serial.println("Waarde teller 1 = " + String(teller1));
Serial.println("Waarde teller 2 = " + String(teller2));
Serial.println();
}
delay(5);
}
if (status_blauw != status_blauw_eerder) {
status_blauw_eerder = status_blauw;
if (status_blauw == 0) {
teller1 = 0;
teller2 ++;
Serial.println("Waarde teller 1 = " + String(teller1));
Serial.println("Waarde teller 2 = " + String(teller2));
Serial.println();
}
delay(5);
}
if (status_geel != status_geel_eerder) {
status_geel_eerder = status_geel;
if (status_geel == 0) {
teller1 = 0;
Serial.println("Waarde teller 1 = " + String(teller1));
Serial.println("Waarde teller 2 = " + String(teller2));
Serial.println();
}
delay(5);
}
if (status_rood != status_rood_eerder) {
status_rood_eerder = status_rood;
if (status_rood == 0) {
teller2 = 0;
Serial.println("Waarde teller 1 = " + String(teller1));
Serial.println("Waarde teller 2 = " + String(teller2));
Serial.println();
}
delay(5);
}
}