Two I²C displays simultaneously on the Arduino
FunduinoPublished on
I²C-Adressen verstehen, ändern und zwei Displays getrennt beschreiben
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-to-Male - 40 Pieces, 20 cm
1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
LED 5 mm - 100 Pieces, 5 Colors, 2 V
1,97 € *Item no. F23107316About the product — LED 5 mm - 100 Pieces, 5 Colors, 2 V
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 6 parts together 22,49 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
Two displays on one bus
Change the address using solder bridges
1 / 2
Read the address using the I²C scanner
I²C scanner
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
#include <Wire.h>
void setup() {
Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning …");
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}Install the library
Connect and program two displays
Two displays with different text
#include <Wire.h> // Include the Wire library
#include <LiquidCrystal_I2C.h> // Include the previously added LiquidCrystal_I2C library
LiquidCrystal_I2C lcd1(0x27, 16, 2); //Here the first display is named (address/characters per line/number of lines). In our case, “lcd1”. The address of the I²C display may vary depending on the module.
LiquidCrystal_I2C lcd2(0x3F, 16, 2); //Here the second LCD is named, here "lcd2".
void setup()
{
lcd1.init(); //In setup, LCD1 is started
lcd2.init(); //In setup, LCD2 is started
lcd1.backlight(); //Turn on LCD1's backlight (0 turns the backlight off).
lcd2.backlight(); //Turn on LCD2's backlight (0 turns the backlight off).
}
void loop()
{
lcd1.setCursor(0,0); //The following text should start at the first character in the first line on LCD1.
lcd1.print("Display1 Zeile 1"); //The text “Display1 Zeile 1” should be displayed on the first line
lcd1.setCursor(0,1); //The following text should start at the first character in the second line on LCD1.
lcd1.print("Display1 Zeile 2"); //The text “Display1 Zeile 2” should be displayed on the second line
lcd2.setCursor(0,0); //The following text should start at the first character in the first line on LCD2.
lcd2.print("Display2 Zeile 1"); //The text “Display2 Zeile 1” should be displayed on the first line
lcd2.setCursor(0,1); //The following text should start at the first character in the second line on LCD2.
lcd2.print("Display2 Zeile 2"); //The text “Display2 Zeile 2” should be displayed on the second line
}Rate the instructions