The LCD 16×2 I2C device also shared 0x27
I had to find the soldering iron and solder shut A0, A1, or A2.
A0 = 1
A1 = 2
A2 = 4
I did A2. The address changed from 0x27 to 0x23.
Scanning…
I2C device found at address 0x01 !
I2C device found at address 0x02 !
I2C device found at address 0x03 !
I2C device found at address 0x04 !
I2C device found at address 0x23 !
I2C device found at address 0x27 !
Each I2C LCD screen has three pads: A0, A1, and A2. Below is the table that shows how to solder the pads to change the address. Below the table is a picture of the I2C LCD screen pads on the right side. Soldering them can be tricky to do.
A0 | A1 | A2 | Hex |
open | open | open | 0x27 |
closed | open | open | 0x26 |
open | closed | open | 0x25 |
closed | closed | open | 0x24 |
open | open | closed | 0x23 |
closed | open | closed | 0x22 |
open | closed | closed | 0x21 |
closed | closed | closed | 0x20 |
#include <LiquidCrystal.h>
#include <Wire.h>
Is missing from the code below due to WordPress formatting
// Include the required Wire library for I2C
// Include the libraries:
// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
#include <LiquidCrystal.h> // Library for I2C communication
#include <Wire.h> // Library for LCD
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd16x2_23 = LiquidCrystal_I2C(0x23, 16, 2); // Change to (0x23,16,2) for 16×2 LCD.
LiquidCrystal_I2C lcd20x4_27 = LiquidCrystal_I2C(0x27, 20, 4); // Change to (0x27,20,4) for 20×4 LCD.
#include
int x = 0;
int LED = 13;
void setup()
{
// Initiate the LCD:
lcd16x2_23.init();
lcd16x2_23.backlight();
lcd20x4_27.init();
lcd20x4_27.backlight();
// I2C counter for LEDs
pinMode (LED, OUTPUT);
// Start the I2C Bus as Master
Wire.begin();
// I2C counter for LEDs
/*
// I2C Scanner Code
Serial.begin(9600);
while (!Serial); // wait for serial monitor
Serial.println(“\nI2C Scanner”);
// I2C Scanner Code
*/
}
void loop() {
//LCD I2C 160X2_23
lcd16x2_23.setCursor(3, 0); // 4th column 1st row
lcd16x2_23.print(“I am 0x23”);
//LCD I2C 20X4
lcd20x4_27.setCursor(3, 0); // 4th column 1st row
lcd20x4_27.print(“Welcome aboard”);
lcd20x4_27.setCursor(8, 1); // 9th column 2nd row
lcd20x4_27.print(“the”);
lcd20x4_27.setCursor(6, 2); // 7th column 3rd row
lcd20x4_27.print(“Heart of”);
lcd20x4_27.setCursor(2, 3); // 3rd column 4th row
lcd20x4_27.print(“Stainless Steel”);
//LCD I2C 20X4
// I2C counter for LEDs
x++; // Increment x
//From Left to Right
// First UNO
Wire.beginTransmission(1); // transmit to device #1
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
//Second UNO
Wire.beginTransmission(2); // transmit to device #2
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
//Mega in the Middle
//Third UNO
Wire.beginTransmission(3); // transmit to device #3
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
//Fourth UNO
Wire.beginTransmission(4); // transmit to device #4
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
if ( (x == 3) || (x == 6)) {
digitalWrite(LED, HIGH);
}
else {
digitalWrite(LED, LOW);
}
if (x == 7) x = 0; // `reset x once it gets 6
delay(1000);
// I2C counter for LEDs
/*
// I2C Scanner Code
byte error, address;
int nDevices;
Serial.println(“Scanning…”);
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print(“I2C device found at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.print(address,HEX);
Serial.println(” !”);
nDevices++;
}
else if (error==4)
{
Serial.print(“Unknown error at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println(“No I2C devices found\n”);
else
Serial.println(“done\n”);
delay(5000); // wait 5 seconds for next scan
// I2C Scanner Code
*/
}
// Include the required Wire library for I2C
// Include the libraries:
// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
#include // Library for I2C communication
#include // Library for LCD
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd16x2_23 = LiquidCrystal_I2C(0x23, 16, 2); // Change to (0x23,16,2) for 16×2 LCD.
LiquidCrystal_I2C lcd20x4_27 = LiquidCrystal_I2C(0x27, 20, 4); // Change to (0x27,20,4) for 20×4 LCD.
#include
int x = 0;
int LED = 13;
void setup()
{
// Initiate the LCD:
lcd16x2_23.init();
lcd16x2_23.backlight();
lcd20x4_27.init();
lcd20x4_27.backlight();
// I2C counter for LEDs
pinMode (LED, OUTPUT);
// Start the I2C Bus as Master
Wire.begin();
// I2C counter for LEDs
/*
// I2C Scanner Code
Serial.begin(9600);
while (!Serial); // wait for serial monitor
Serial.println(“\nI2C Scanner”);
// I2C Scanner Code
*/
}
void loop() {
//LCD I2C 160X2_23
lcd16x2_23.setCursor(3, 0); // 4th column 1st row
lcd16x2_23.print(“I am 0x23”);
//LCD I2C 20X4
lcd20x4_27.setCursor(3, 0); // 4th column 1st row
lcd20x4_27.print(“Welcome aboard”);
lcd20x4_27.setCursor(8, 1); // 9th column 2nd row
lcd20x4_27.print(“the”);
lcd20x4_27.setCursor(6, 2); // 7th column 3rd row
lcd20x4_27.print(“Heart of”);
lcd20x4_27.setCursor(2, 3); // 3rd column 4th row
lcd20x4_27.print(“Stainless Steel”);
//LCD I2C 20X4
// I2C counter for LEDs
x++; // Increment x
//From Left to Right
// First UNO
Wire.beginTransmission(1); // transmit to device #1
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
//Second UNO
Wire.beginTransmission(2); // transmit to device #2
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
//Mega in the Middle
//Third UNO
Wire.beginTransmission(3); // transmit to device #3
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
//Fourth UNO
Wire.beginTransmission(4); // transmit to device #4
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
if ( (x == 3) || (x == 6)) {
digitalWrite(LED, HIGH);
}
else {
digitalWrite(LED, LOW);
}
if (x == 7) x = 0; // `reset x once it gets 6
delay(1000);
// I2C counter for LEDs
/*
// I2C Scanner Code
byte error, address;
int nDevices;
Serial.println(“Scanning…”);
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print(“I2C device found at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.print(address,HEX);
Serial.println(” !”);
nDevices++;
}
else if (error==4)
{
Serial.print(“Unknown error at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println(“No I2C devices found\n”);
else
Serial.println(“done\n”);
delay(5000); // wait 5 seconds for next scan
// I2C Scanner Code
*/
}