I will create a complete single file sketch for ESP32 on Wokwi simulator with 3 LEDs (red, yellow, green) and a 20x4 LCD display. The LCD will be connected via I2C using pins SDA=12 and SCL=13. On the LCD, the text "aku anhar hello" should appear.
Plan:
- Use Arduino framework syntax for ESP32
- Define pins for red, yellow, green LEDs, and initialize them as output.
- Use LiquidCrystal_I2C library for the 20x4 LCD display.
- Initialize I2C with SDA=12, SCL=13.
- Display "aku anhar hello" on the LCD at row 0, col 0.
- Turn on the LEDs sequentially or all turned off by default (since user didn't specify blinking).
- Add modern and clean styling for readability on LCD (although limited by hardware).
- Make sure code is compatible with Wokwi ESP32.
Next, I'll create the complete code with inline comments.
`esp32_led_lcd_wokwi.ino`
```ino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Define pins for LEDs
const int redLedPin = 14; // Red LED pin
const int yellowLedPin = D2; // Yellow LED pin
const int greenLedPin = 25; // Green LED pin
// Initialize the LCD, address 0x27 is common, 20 columns x 4 rows
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
// Initialize LED pins as outputs
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
// Initialize I2C pins (SDA=12, SCL=13)
Wire.begin(12, 13);
// Initialize LCD
lcd.init();
lcd.backlight(); // Turn on the backlight
// Display the desired message
lcd.setCursor(0, 0); // column 0, row 0
lcd.print("aku anhar hello");
// Turn off all LEDs initially
digitalWrite(redLedPin, LOW);
digitalWrite(yellowLedPin, LOW);
digitalWrite(greenLedPin, LOW);
}
void loop() {
// No blinking or changes defined by the user, so keep LEDs off or could cycle
// Here for demonstration, cycle LEDs on and off every 1 second
digitalWrite(redLedPin, HIGH);
delay(1000);
digitalWrite(redLedPin, LOW);
digitalWrite(yellowLedPin, HIGH);
delay(1000);
digitalWrite(yellowLedPin, LOW);
digitalWrite(greenLedPin, HIGH);
delay(1000);
digitalWrite(greenLedPin, LOW);
}
```