#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int potentiometerPin = A0;
const int threshold = 512; // Пороговое значение
void setup() {
lcd.begin(16, 2);
lcd.print("Smoke Detector");
delay(1000);
lcd.clear();
lcd.print("RA252 BY UZAP");
delay(1000);
lcd.clear();
showLoadingBar();
lcd.clear();
lcd.print("OK");
}
void loop() {
int potValue = analogRead(potentiometerPin);
if (potValue >= threshold) {
lcd.clear();
lcd.print("WARNING FIRE");
while (potValue >= threshold) {
potValue = analogRead(potentiometerPin);
delay(100);
}
lcd.clear();
lcd.print("OK");
}
delay(100);
}
void showLoadingBar() {
for (int i = 0; i <= 100; i++) {
displayProgressBar(i);
delay(50);
}
}
void displayProgressBar(int percent) {
lcd.setCursor(0, 1);
lcd.print("[");
for (int i = 0; i < 14; i++) {
if (i < (percent / 6)) {
lcd.write((byte)255);
} else {
lcd.print(" ");
}
}
lcd.print("]");
lcd.print(percent);
lcd.print("%");
}