const int buttonPins[] = {13,12,8,7};
int buttonState;
void setup(){
Serial.begin(115200);
// Setup buttons as input
for (int i = 0; i < 4; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
}
void loop(){
for (int i = 0; i < 4; i++) {
buttonState = digitalRead(buttonPins[i]);
if (buttonState == LOW) {
handleButtonPress(i); // Behandel knopdrukken
delay(400); // Debounce vertraging
}
}
}
void handleButtonPress(int button) {
switch (button) {
case 0: // LED's toggelen
Serial.println("Button 1 is pressed - Turn on/off lights");
systemRunning = false; // Stop elke lopende actie
toggleLEDs();
break;
case 1: // Sequentiële animatie
Serial.println("Knop 2 ingedrukt - Sequentiële Animatie");
animationType = 1;
animationRunning = !animationRunning;
break;
case 2: // Binnen-Buiten animatie
Serial.println("Knop 3 ingedrukt - Binnen-Buiten Animatie");
animationType = 2;
animationRunning = !animationRunning;
break;
case 3: // Willekeurige LED aan/uit
Serial.println("Knop 4 ingedrukt - Willekeurige LED Aan/Uit");
animationType = 3;
animationRunning = !animationRunning;
break;
}
}
KITCHEN
LIVING
BATHROOM
VENTILATOR
LIGHT-SENSOR
TEMPERATURE
& HUMIDITY