//Created by Barbu Vulc!
//Using an ESP32 board at its full potential!
//Libraries:
#include <WiFi.h>
#include <LiquidCrystal_I2C.h>
//Create LCD object:
LiquidCrystal_I2C lcd(0x27, 16, 2);
//LED variables:
const int LED_blue = 15, LED_red = 4;
//WiFi connection...
void setup() {
//Initiate serial communication & I2C LCD:
Serial.begin(115200);
lcd.init(); lcd.backlight();
//Verify if the WiFi connection is successfully done:
Serial.print("Connected to WiFi!");
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println("Connected!");
delay(100);
//LEDs' initialization:
pinMode(LED_blue, OUTPUT); pinMode(LED_red, OUTPUT);
}
//The project...
void loop() {
if (WiFi.status() == WL_CONNECTED) {
//Red - LOW, Blue - HIGH
lcd.setCursor(0, 0); lcd.print("Red LED - LOW");
lcd.setCursor(0, 1); lcd.print("Blue LED - HIGH");
digitalWrite(LED_blue, HIGH);
digitalWrite(LED_red, LOW);
delay(1000); lcd.clear();
//Red - HIGH, Blue - LOW
lcd.setCursor(0, 0); lcd.print("Red LED - HIGH");
lcd.setCursor(0, 1); lcd.print("Blue LED - LOW");
digitalWrite(LED_red, HIGH);
digitalWrite(LED_blue, LOW);
delay(1000); lcd.clear();
}else{
//In case the WiFi connection is interrupted for some reason!
lcd.setCursor(0, 0); lcd.print("Connection");
lcd.setCursor(0, 1); lcd.print("is lost!");
digitalWrite(LED_red, LOW); digitalWrite(LED_blue, LOW);
}
}