#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP32Servo.h>
#define botao 5
LiquidCrystal_I2C LCD (0x27, 16, 2);
const int servoPin = 16;
Servo servoMotor;
bool ler_bot = 0;
int trava = 0;
int graus = 0;
int contagem = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
servoMotor.attach(servoPin);
pinMode(botao, INPUT);
LCD.init();
LCD.backlight();
LCD.clear();
}
void loop() {
ler_bot = digitalRead(botao);
if (ler_bot == 1 && trava == 0){
trava = 1;
}
if (ler_bot == 0 && trava == 1){
contagem++;
graus = (contagem * 10) % 181;
trava = 0;
}
servoMotor.write(graus);
LCD.setCursor(0,0);
LCD.print("contagem de clicks");
LCD.setCursor(0,1);
LCD.print(contagem);
}