Hi, @arthurfogo7
Welcome to the forum.
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
@arthurfogo7 code.
SERVO_CLOSED_POSITION);
isDoorOpen = false;
Blynk.virtualWrite(V0, F("Porta está Fechada"));
Blynk.virtualWrite(DoorStateLedPin, LED_OFF);
}
void sendDoorStatus() {
byte MC38State = digitalRead(mc38SensorPin);
if (MC38State == HIGH) {
if (!isDoorOpen) {
openDoor();
}
} else {
if (isDoorOpen) {
closeDoor();
}
}
}
BLYNK_WRITE(ActivateButtonPin) {
if (param.asInt() == 1) {
if (isDoorOpen) {
closeDoor();
} else {
openDoor();
}
}
}
void setup() {
Serial.begin(SERIAL_BAUD_RATE);
espSerial.begin(115200); // ESP-01 communication
// Wait for ESP-01 to be ready
delay(1000);
// Send an AT command to check the connection
espSerial.println("AT");
delay(500);
// Read and print the response from ESP-01
while (espSerial.available()) {
char c = espSerial.read();
Serial.print(c);
}
pinMode(mc38SensorPin, INPUT);
ESP8266 wifi(&espSerial);
Blynk.begin(auth, wifi, ssid, pass, BLYNK_TEMPLATE_ID, BLYNK_TEMPLATE_NAME);
blynkTimer.setInterval(TIMER_INTERVAL, sendDoorStatus);
terminal.clear();
terminal.println(F("Blynk v" BLYNK_VERSION ": Dispositivo iniciado"));
terminal.println(F("-------------"));
terminal.flush();
}
void loop() {
Blynk.run();
blynkTimer.run();
}
Tom..