Werktags vor 14:00 Uhr bestellt = am selben Tag versendet 30 Tage Widerrufsrecht 1 Jahr Garantie
← Zurück zur Übersicht

Beim Abspielen wird das Video von YouTube geladen.

Schaltplan und Codebeispiel

So schließt du den LCD 1602/2004 I2C-Adapter an einen Arduino UNO oder ESP32 an, mit einem Beispiel-Sketch, den du direkt hochladen kannst.

1602 I2C LCD Display Demo

Dieses Projekt zeigt, wie man ein 1602-LCD-Modul mit einem I2C-Backpack anschließt und Text darauf anzeigt. Es initialisiert das Display, schaltet die Hintergrundbeleuchtung ein und gibt eine Begrüßung zusammen mit einem Live-Uptime-Zähler aus. Stelle das Potentiometer auf der Rückseite des Moduls ein, wenn der Textkontrast zu hoch oder zu niedrig ist.

Anschlussplan: LCD 1602/2004 I2C-Adapter an einem Arduino UNO
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: LCD 1602/2004 I2C-Adapter an einem Arduino UNO
Anschlusstabelle · Zum Vergrößern klicken
1602_I2C_LCD_Display_Demo.ino · kompiliert und getestet
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : 1602 I2C LCD Display Demo
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : 1602 LCD I2C DISPLAY
 *  Libraries : LiquidCrystal I2C 1.1.2
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Most 1602 I2C modules use address 0x27 or 0x3F
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(115200);
  
  lcd.init();
  lcd.backlight();
  
  lcd.setCursor(0, 0);
  lcd.print("Hello, Arduino!");
  lcd.setCursor(0, 1);
  lcd.print("Uptime: 0s");
  
  Serial.println(F("1602 LCD display initialized."));
}

void loop() {
  static unsigned long seconds = 0;
  
  delay(1000);
  seconds++;
  
  lcd.setCursor(8, 1);
  lcd.print(seconds);
  lcd.print("s   ");
  
  Serial.print(F("Uptime (s): "));
  Serial.println(seconds);
}

Benötigte Bibliotheken: LiquidCrystal I2C 1.1.2

Wiring diagram and example code generated by Codey.online — https://www.codey.online

ESP32 1602 I2C LCD-Display-Demo

Dieses Projekt zeigt eine Willkommensnachricht und einen Laufzeit-Zähler auf einem 1602 I2C-Zeichen-LCD an. Ein bidirektionaler 4-Kanal-Logic-Level-Shifter wird verwendet, um die 3.3V-I2C-Signale des ESP32 sicher an die 5V-Logik anzupassen, die für das LCD-Backpack erforderlich ist. Nach dem Einschalten initialisiert sich das LCD und aktualisiert die laufenden Sekunden jede Sekunde.

Anschlussplan: LCD 1602/2004 I2C-Adapter an einem ESP32 DevKit V1
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: LCD 1602/2004 I2C-Adapter an einem ESP32 DevKit V1
Anschlusstabelle · Zum Vergrößern klicken
ESP32_1602_I2C_LCD_Display_Demo.ino · kompiliert und getestet
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 1602 I2C LCD Display Demo
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : 1602 LCD I2C DISPLAY
 *  Libraries : LiquidCrystal I2C 1.1.2
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address (commonly 0x27 or 0x3F) for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(115200);

  // Initialize I2C communication (SDA = GPIO 21, SCL = GPIO 22)
  Wire.begin(21, 22);

  // Initialize the LCD
  lcd.init();
  lcd.backlight();

  // Print greeting
  lcd.setCursor(0, 0);
  lcd.print("ESP32 LCD Demo");
  lcd.setCursor(0, 1);
  lcd.print("Uptime: 0s");

  Serial.println("1602 LCD Initialized!");
}

void loop() {
  // Update uptime counter every second
  static unsigned long lastUpdate = 0;
  if (millis() - lastUpdate >= 1000) {
    lastUpdate = millis();
    unsigned long seconds = millis() / 1000;

    lcd.setCursor(8, 1);
    lcd.print(seconds);
    lcd.print("s   ");

    Serial.print("Uptime: ");
    Serial.print(seconds);
    Serial.println(" s");
  }
}

Benötigte Bibliotheken: LiquidCrystal I2C 1.1.2

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Zuletzt angesehen

USB-A Breakout-Board

USB-A Breakout-Board

€ 0,70
RGB Sensor Modul TCS34725

RGB Sensor Modul TCS34725

€ 5,05
XT60 Buchse

XT60 Buchse

€ 1,49
XT90 Buchse

XT90 Buchse

€ 1,69
Ansehen
Potentiometer 10K Linear

Potentiometer 10K Linear

€ 0,90