Control an I²C LCD with an Arduino
FunduinoLast updated on
Text und Messwerte mit nur vier Leitungen anzeigen
You need this
1602 I2C LCD Module - 2x16 Characters, HD44780, Blue
3,02 € *Item no. FUN-1010568About the product — 1602 I2C LCD Module - 2x16 Characters, HD44780, Blue
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard cables male-female - 40 pieces, 20 cm
1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm
All 4 parts together 18,78 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
The I²C LCD
The I²C address
1 / 2
The wiring
Install the library
The program
Text on the I²C LCD
#include <Wire.h> // Include the Wire library
#include <LiquidCrystal_I2C.h> // Include the previously added LiquidCrystal_I2C library
LiquidCrystal_I2C lcd(0x27, 16, 2); //Here you specify the type of display. In this case, one with 16 characters in 2 lines and the HEX address 0x27. For a four-line I2C LCD, use the code "LiquidCrystal_I2C lcd(0x27, 20, 4)"
void setup()
{
lcd.init(); //The LCD is initialized in setup
lcd.backlight(); //Turn on the backlight (lcd.noBacklight(); turns off the backlight).
}
void loop()
{
lcd.setCursor(0, 0);//Here you specify the position of the first character. In this case, (0,0) means the first character in the first line.
lcd.print("Funduino GmbH");
lcd.setCursor(0, 1);// In this case, (0,1) means the first character in the second line.
lcd.print("Good luck!");
}Extension: display a measurement value
Display the measured value on the I²C LCD
#include <Wire.h> // Include the Wire library
#include <LiquidCrystal_I2C.h> // Include the previously added LiquidCrystal_I2C library
LiquidCrystal_I2C lcd(0x27, 16, 2); // Specifies the display type. The HEX address 0x27 is a standard address for LCDs with a simple I²C module on the back. If the I²C module has solder pads for changing the HEX address, the standard address is "0x3F". In this case, this is an LCD with 16 characters in 2 lines (16,2). For a four-line I2C LCD, use the code "LiquidCrystal_I2C lcd(0x27, 20, 4)".
int messwert=0;
void setup()
{
lcd.init(); // Initialize the LCD in setup
lcd.backlight(); // Turn on the backlight (lcd.noBacklight(); turns off the backlight).
}
void loop()
{
messwert=analogRead(A0); // Read the measurement from analog input A0 and store it in the variable "messwert".
lcd.setCursor(0, 0); // Sets the position of the first character. In this case, (0,0) means the first character in the first line.
lcd.print("Messwert: ");
lcd.setCursor(0, 1); // In this case, (0,1) means the first character in the second line.
lcd.print(messwert);
delay(500);
}Rate the instructions