int botonPin1 = 2;
int botonPin2 = 3;
int botonPin3 = 4;
int botonPin4 = 5;
int ledPin1 = 6;
int ledPin2 = 7;
int buzzPin1 = 8;
int buzzPin2 = 9;
void runSequence(int duration, int pin1, int pin2) {
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
delay(duration);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
delay(duration);
}
void setup() {
pinMode(botonPin1, INPUT);
pinMode(botonPin2, INPUT);
pinMode(botonPin3, INPUT);
pinMode(botonPin4, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(buzzPin1, OUTPUT);
pinMode(buzzPin2, OUTPUT);
}
void loop() {
if (digitalRead(botonPin1) == HIGH) {
runSequence(500, ledPin1, ledPin2);
delay(100); //
}
if (digitalRead(botonPin2) == HIGH) {
runSequence(500, buzzPin1, buzzPin2);
delay(100);
}
if (digitalRead(botonPin3) == HIGH || digitalRead(botonPin4) == HIGH) {
runSequence(500, ledPin1, buzzPin1);
runSequence(500, ledPin2, buzzPin2);
delay(100);
}
if (digitalRead(botonPin3) == HIGH && digitalRead(botonPin4) == HIGH) {
runSequence(300, ledPin2, buzzPin1);
runSequence(300, ledPin1, buzzPin2);
delay(100);
}
}