#include <ESP32Servo.h>;
Servo servo;
const int servoPin = 22;
const int botsel = 15; //pin do botão
int est_bot = 0; //estado do botão
int pos = 0;
const int abrir = 2;
const int fechar = 4;
int b_abrir = 0;
int b_fechar = 0;
int s_t = 0;
const int sensor_temp = 34;
const int autom = 18;
const int manual = 19;
int aux_abertura = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(sensor_temp, INPUT);
pinMode(abrir, INPUT);
pinMode(fechar, INPUT);
pinMode(botsel, INPUT);
pinMode(autom, OUTPUT);
pinMode(manual, OUTPUT);
servo.attach(servoPin, 500, 2400);
}
void loop() {
if(est_bot == HIGH){
digitalWrite(manual, HIGH);
digitalWrite(autom, LOW);
b_abrir = digitalRead(abrir);
if(b_abrir == HIGH){
for(int i = 0; i<180;i++){
servo.write(i);
delay(10);
}
}
b_fechar = digitalRead(fechar);
if(b_fechar == HIGH){
for(int i = 180; i<0;i--){
servo.write(i);
delay(10);
}
} else {
digitalWrite(manual, LOW);
digitalWrite(autom, HIGH);
delay(10);
}
}
}