#include <LiquidCrystal.h>
#include <Servo.h>
#include <GyverEncoder.h>
#define CLK 3
#define DT 4
#define SW 5
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
const int buzzerPin = A0;
Servo servo1;
Encoder enc1(CLK, DT, SW);
String password_input = "";
String End = "";
typedef enum {
SET_1,
SET_2,
SET_3,
SET_4,
SET_5,
} Mode;
Mode mode = SET_1;
int pos = 0;
int counter = 21;
int pose1 = 2;
int counter1 = 0;
int counter2 = 0;
int currentStateCLK;
int lastStateCLK;
String currentDir ="";
unsigned long lastButtonPress = 0;
String text = "VVedite parol";
int textLength = text.length();
int prevPos = 0;
void nextMode() {
switch (mode) {
case SET_1:
mode = SET_2;
break;
case SET_2:
mode = SET_3;
break;
case SET_3:
mode = SET_4;
break;
case SET_4:
mode = SET_5;
break;
}
}
void setup() {
pinMode(6, OUTPUT);
pinMode(SW, INPUT_PULLUP);
pinMode(CLK,INPUT);
pinMode(DT,INPUT);
lcd.begin(16, 2); // Инициализация LCD
lcd.setCursor(0, 0); // Установка курсора на начало экрана
lcd.print(text);
servo1.attach(7);
Serial.begin(115200);
lastStateCLK = digitalRead(CLK);
}
int lastClk = HIGH;
void loop() {
int newClk = digitalRead(CLK);
if (newClk != lastClk) {
lastClk = newClk;
int dtValue = digitalRead(DT);
if (newClk == LOW && dtValue == HIGH) {
counter--;
lcd.setCursor(pos,2);
lcd.println(counter);
}
if (newClk == LOW && dtValue == LOW) {
counter1++;
lcd.setCursor(pos,2);
lcd.println(counter1);
}
if (counter1 >= 19 ){
counter1 = 0;
}
if (counter <= 1 ){
counter = 21;
}
}
if (digitalRead(SW) == LOW) {
for (pos = 0; pos < pose1; pos++){
}
}
}