#include <LiquidCrystal.h> // Библиотека дисплей
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int bovb = 40;
const int PIN_RED = 20;
const int PIN_GREEN = 21;
const int switchPin = 4;
void setup() {
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH);
lcd.begin(16, 2);
pinMode(PIN_RED, OUTPUT);
pinMode(PIN_GREEN, OUTPUT);
pinMode(18, OUTPUT);
Serial.begin(9200);
Serial.println("Start");
}
void loop() {
int switchState = digitalRead(switchPin);
if (switchState == LOW) {
lcd.print("______00:" + String(bovb) + "______");
delay(1000);
lcd.clear();
bovb = bovb - 1;
delay(300);
delay(bovb);
tone(18, 600);
setColor(255, 0);
delay(bovb);
noTone(18);
setColor(0, 0);
} else {
}
if (bovb == 0) {
lcd.print("Boom");
setColor(0, 0);
setColor(0, 255);
tone(18, 1000);
delay(1000);
noTone(18);
Serial.println("Boom");
}
}
void setColor(int redValue, int greenValue) {
analogWrite(PIN_RED, redValue);
analogWrite(PIN_GREEN, greenValue);
}