lcd16x2displayviai2c
Wiring:
SDA → D2 (GPIO4) SCL → D1 (GPIO5)
PlatformIO:
lib_deps =
marcoschwartz/LiquidCrystal_I2C@^1.1.4
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address (usually 0x27 or 0x3F)
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(115200);
Wire.begin(); // SDA = D2(GPIO4), SCL = D1(GPIO5) on NodeMCU
Serial.println("Initializing LCD...");
// Initialize LCD
lcd.begin(16, 2);
lcd.backlight();
lcd.print("Hello World!");
Serial.println("LCD should be working now");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print("Millis: ");
lcd.print(millis() / 1000);
delay(1000);
}
lcd16x2displayviai2c.txt · Last modified: by jwan
