#include <WiFi.h>
// Define the LED pin (built-in LED for Wokwi ESP32 simulation)
const int ledPin = 2; // Typically, the built-in LED on the ESP32 is on GPIO 2
// Replace with your network credentials
const char* ssid = "Wokwi-GUEST";
const char* password = "";
// Setup function to initialize serial communication, WiFi, and LED
void setup() {
// Start the serial communication
Serial.begin(115200);
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Start connecting to WiFi
Serial.println("Connecting to WiFi...");
WiFi.begin(ssid, password);
// Wait for the connection to succeed
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Once connected, print the IP address and turn on the LED
Serial.println("Connected!");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
digitalWrite(ledPin, HIGH);
}
// Main loop function
void loop() {
// Put your main code here, to run repeatedly
}