#include <ESP32Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int servopin = 27;
Servo servoMotor;
#define BT 4
int set = 0;
int cont2 = 0;
int cont = 0;
byte Graus[] = {
B00000,
B00111,
B00101,
B00111,
B00000,
B00000,
B00000,
B00000
};
LiquidCrystal_I2C LCD((0x27), 16, 2);
void setup() {
Serial.begin(115200);
servoMotor.attach(servopin);
pinMode(4, INPUT);
LCD.init();
LCD.backlight();
LCD.createChar(0, Graus);
LCD.setCursor(0,0);
LCD.print("Ang srvo:/cont:");
}
void loop() {
if(digitalRead(BT) == 1 && set == 0){
cont = cont + 10;
cont2++;
if(cont > 180)cont = 0;
set = 1;
LCD.setCursor(0,1);
LCD.print(cont);
LCD.write(0);
LCD.print(", ");
LCD.print(cont2);
LCD.print(" ");
}
if(digitalRead(BT) == 0 && set == 1){
set = 0;
}
servoMotor.write(cont);
delay(10);
}