- Код: Выделить всё
#define LED1 11
#define LED2 10
#define LED3 5
#define RELE 7
#define BUTTON 12
int val = 0;
int but = 0;
void setup()
{
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(RELE, INPUT);
pinMode(BUTTON, INPUT);
}
void off()
{
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
}
void loop()
{
but = digitalRead(BUTTON);
if (but == HIGH) {
val = digitalRead(RELE);
if (val == HIGH) {
digitalWrite(LED1, HIGH);
delay(1000);
digitalWrite(LED1, LOW);
val = digitalRead(RELE);
if (val == HIGH) {
digitalWrite(LED2, HIGH);
delay(1000);
digitalWrite(LED2, LOW);
}
else {
off;
}
val = digitalRead(RELE);
if (val == HIGH) {
digitalWrite(LED3, HIGH);
delay(1000);
digitalWrite(LED3, LOW);
}
else {
off;
}
} else {
off;
}
}
else {
val = digitalRead(RELE);
if (val == HIGH) {
digitalWrite(LED1, HIGH);
delay(500);
digitalWrite(LED1, LOW);
delay(500);
digitalWrite(LED1, HIGH);
delay(500);
digitalWrite(LED1, LOW);
delay(500);
val = digitalRead(RELE);
if (val == HIGH) {
digitalWrite(LED2, HIGH);
delay(500);
digitalWrite(LED2, LOW);
delay(500);
digitalWrite(LED2, HIGH);
delay(500);
digitalWrite(LED2, LOW);
delay(500);
}
else {
off;
}
val = digitalRead(RELE);
if (val == HIGH) {
digitalWrite(LED3, HIGH);
delay(500);
digitalWrite(LED3, LOW);
delay(500);
digitalWrite(LED3, HIGH);
delay(500);
digitalWrite(LED3, LOW);
delay(500);
}
else {
off;
}
} else {
off;
}
}
}