//Variablen
const int ledpins[]={15,2,4};
const int alarm_button=13;
const int quit_button=12;
const int alarm_led=23;
const int status_led=22;
bool alarm_status = false;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
for (int element : ledpins){
pinMode(element, OUTPUT);
digitalWrite(element, LOW);
}
pinMode(alarm_button, INPUT_PULLUP);
pinMode(quit_button, INPUT_PULLUP);
pinMode(alarm_led, OUTPUT);
pinMode(status_led, OUTPUT);
digitalWrite(status_led, HIGH);
digitalWrite(alarm_led, LOW);
}
void loop() {
if (digitalRead(alarm_button)==LOW){
if (alarm_status == false){
for (int element : ledpins){
digitalWrite(element, HIGH);
Serial.println("Alarm für x!");
}
digitalWrite(alarm_led, HIGH);
alarm_status=true;
Serial.println("");
}
}
if (digitalRead(quit_button)==LOW){
if (alarm_status == true){
for (int element : ledpins){
digitalWrite(element, LOW);
Serial.println("Alarm für x quittiert!");
}
digitalWrite(alarm_led, LOW);
alarm_status = false;
}
}
delay(1000); // this speeds up the simulation
}