I2C/SPI LCD adapter would not work

Hello, I just bought my I2C/SPI LCD adapter, and I’m trying to connect it to my Arduino Uno Rev3. I made the following connections:
A4 (analog pin) → SDAT (on the I2C)
A5 (analog pin) → SCLK (on the I2C)
and of course the +5, ground on both devices.

I have downloaded the library for it, and made sure that it is in my software. I ran the scanning sketch for the I2C, to find out that it can see the device. The scanning shows that it is at 0x20 address. In the program I tried initializing it at 0x20 address. I also read that if my A0, A1, and A2 connections are open it should be initialized at 0x27. I tried both addresses and still nothing. This is the code i uploaded to the arduino:

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

LiquidCrystal_I2C lcd(0x20,16,2); // I also tried with 0x27

void setup()
lcd.init(); // initialize the lcd

// Print a message to the LCD.
lcd.print(“Hello, world!”);

void loop()

PLEASEEE HELPPP!!! I don’t know what else to do. I don’t even know what to look for smiley-sad

It sounds like you need to read this:

Also, when you post code, use the code button, the one with the "#" symbol on it
so it will create a scroll window so people can scroll through the code.

You also need to tell us if you are getting any compile errors.
Also, you can try the I2C library here:

Have you tried adding 4.7k pullup resistors on A4 & A5 ?
Also , you can read here how to do it in software:

If you don't KNOW (that means know it cold) the correct proceedure to change libraries, please say so.

I don't know how to change libraries.

no problem.
You have to delete the old library, which, if it is installed, should be in your My Documents\Arduino\Libraries folder
with a folder name with one of two spellings; either "LiquidCrystal_I2C" or "LiquidCrystal". I am guessing it is the
former. Delete that and install the one at the link I gave you (V1.21) FMalpartida's library.
You can unzip it directly to the My Documents\Arduino\Libraries folder or unzip it somewhere else and copy and
paste the entire folder to your libraries folder. If I were you I would first try "File\Examples\LiquidCrystal\Examples\Helloworld."
If you already tried that then you probably need to go ahead and change libraries. You don't necessarily NEED to delete
the old one, you just need to get it somewhere "far away" (like not in My Documents) . You could be multiple libraries
in a temp folder on a separate drive and copy and paste them when you need them as long as you get the old one
out of there first.

Yes i got it. Thanks.

I researched a bit and it seem like a lot of people are having problems with the exact type of LCD. I tried different libraries, and non of them worked. Not only that they didn’t work, but some of them were giving completely different errors. Could it be programming problem? And what is the best library that would actually work?


It's not that simple.
Even if the library is correct, it won't work if the lcd constructor (config descriptor) is not correct.
If you don't already have that info it looks like you need to use the "Guesser"
You also need to post the link to where you bought it.
The scanner only tells you the address , the guesser tells you the constructor and actually displays it on
the lcd when it finds a match so you have to look at it after each "guess".
You might need to change you serial monitor line ending to "Newline " for the guesser to work.
Read the instructions in the program.

First thing S-L-O-W D-O-W-N.
Just running around guessing at things isn't' a very good way to try to reach a working solution.
Random trial can sometimes lead to a solution, but even if it does, it sure
wastes lots of time and energy.
It can also create additional issues/problems or even damage the hardware.

First things first.
You have never stated which lcd backpack you have.

I know of only one I2C/SPI adapter (the #210 from Adafruit)
and that one doesn't use a PCF8574 i2c chip which is what nearly
all the other backpacks use. (It also isn't really SPI either)

There are also some backpacks, that have i2c,serial, & spi, but those
are even less common. A few of them have to be jumpered
to select which interface to use.

So tell us which lcd backpack do you have?
Can you post a photo of it?

Before anyone can offer anything other than just guesses,
we have to know which lcd backpack you have so we know what
library is appropriate for it.

--- bill

You also need to post the link to where you bought it.

So tell us which lcd backpack do you have?

The have the one from adarfuit ID: 292.
You can see the link here --> i2c / SPI character LCD backpack : ID 292 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits

According to this page there are jumpers, and here it shows Address#0 to 3

Why don't you try using SPI mode ?

Ah, the Adafruit #292, oops that is the backpack I meant rather than #210.
That is is the board I was talking about earlier.

It can run in "i2c" mode or "spi" mode.

That board uses a MCP23008, so none of the more common "LiquidCrystal_I2C" libraries floating
around will work, since they only support the PCF8574 chip.

That board also doesn't really have a SPI interface, it has a 74HC595 on it and
uses a 3 wire shift register interface - which is not SPI.

You have a few choices, you can use the Adafruit MCP23008 i2c library
(which Adafruit supplies, you just need to go to their site, download and install it)
or you could re-strap the board (requires soldering a jumper) and run it in shift register
mode - which Adafruit calls "SPI" mode. You can see the solder jumper on the board
labeled "SPI Enable" which must be soldered to disable i2c and enable shift register mode.
If you run it in shift register mode, you will need to download and install fm's library.
Then use this constructor:

LiquidCrystal_SR3W lcd(DatPin, ClkPin, LatPin, 2,0,1,6,5,4,3,7, POSITIVE);

I also have a unreleased i2c interface class for fm's library that supports the MCP2308,
however, since it appears you have limited h/w & s/w experience, I'd recommend using the
adafruit library and if you have any issues go over to the adafruit tech forum

and get support from her. She is very good about supporting her products.

One thing that is very different when using the adafruit library is that the "address"
you supply isn't really the i2c address. It is the value you have jumpered.
So make sure to only fill in the jumpered address (a value zero to seven) vs the actual i2c address
if you don't, then the library will use address 0x27, which with a default board will be wrong.
(I think this is a very dumb way of doing things, and I reported it to Adafruit)

--- bill

According to this page there are jumpers, and here it shows Address#0 to 3
Arduino I2C Use | i2c/SPI LCD Backpack | Adafruit Learning System

The i2c addresses is set by 3 jumpers that support addresses from 0 to 7.
If you look at the schematic for the backpack, the jumpers are wired directly to the
MCP23008 A0, A1, and A2 pins.
The example they show just happens to set the jumpers for 3.

I have one of these boards.
I use it in i2c mode with fm's library with my own IIC class which supports the MCP23008.
On the same backpack, my IIC class is around 7 times faster than the AdaFruit library.
AdaFruit takes 4000us per byte transfer and mine is 645us
or around 7 FPS vs 45 FPS on a 16x2 display - which is noticeable.
and using my IIC class and a PCF8574 based backpack: 544us and 54 FPS
(fm's i2c class is 957us and 31 FPS)

Overall, the board works fine in either i2c or shift register mode,
but I don't care for it, and would not recommend it to others.
The main reason is that it uses the MCP23008 which has less support than the PCF8574
and it has more overhead due to the way the chip interface works, so it will always
be slower than than a PCF8574 based board.

Just my preference but I don't care for the screw terminals. I prefer a 4 pin connector
that uses this pin ordering: GND, VCC, SDA, SCL
as that is compatible with many of the 3rd party Arduinos and shields that
provide i2c headers/connectors and allows using a simple 4 wire cable.

Also, having both i2c and shift register interfaces adds unnecessary cost to the board,
if all you want/need is an i2c backpack.

--- bill

Thanks for your replies guys. I updated the library and tried this code:

#include <Adafruit_MCP23008.h>
#include <Wire.h>
Adafruit_MCP23008 lcd(0);

void setup()
void loop()

I tried to get the code, adafruit provides but it couldn’t get it. Please help.

You appear to be mis-using the library.
Does that code you provided even compile?, I'm guess it doesn't.

The adafruit LiquidCrystal library comes with 11 examples, including
a HelloWorld_i2c example.

The HelloWorld_i2c example will run with an "out of the box" #292 backpack
with no modifications needed to the h/w or s/w sketch.
(I just ran it a little while ago)

You should be able to run it "as is" on your backpack.

You can take a look at that example for the proper way to use the library.
If you don't see the 11 examples, and a HelloWorld_i2c example,
then you have the wrong library.

You can find the link to the Adafruit library in the download section of
the tutorial that raschemmel referenced earlier
The link to the tutorial is on the product page in bold blue letters at the bottom
of the description.
Here it is in case you missed it: Overview | i2c/SPI LCD Backpack | Adafruit Learning System
The download section in that tutorial has instructions where to get the library
and how to install it.

Slow Down, and stop doing trial and error guessing.
Spend some time to read through the tutorial,
all the information you need to get the backpack up and running is in that tutorial.

--- bill

Hi Bill,
no it doesn't compile. I was going to writ the exact error, but I'm going to try the examples. I forgot that they were in the folder. I'm not sure if I should use the "LiquidCrystal.h" name for including the header file, of use the "Adafruit_MCP23008.h" name.

I tried the following code it an example from adafruit:

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"

// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:


It gives me the following error: 'LiquidCrystal' does not name a type.

Have you taken the time to read through the full tutorial?
If not, I suggest you take the time to carefully read through all of it as it has all the information
you need.

--- bill

Have you taken the time to read through the full tutorial?

Yes i did, a couple of times. I’m not so good at the programming Arduino uses, so I need some help with the error it is giving me.

I researched about this error, and it means that the code is not recognizing the library. I placed the library exactly where the tutorial says. Do I have to have another line of code that will recognize the library?

All that is required is to place the library where the original LiquidCrystal library was.
While not mentioned in the instructions, you could also leave the original LiquidCrystal
library alone and put this library in your personal libraries directory and it would override
the original LiquidCrystal library. (personal libraries have priority over the libraries that come with the IDE
when the header files are the same name).

Other than that, you do have to exit and restart the IDE in order to get the IDE to see the new

You don't have to change/alter any code or do any programming.
The included HelloWorld_i2c example sketch will work "as is" on a "out of the box" #292 backpack
when all the files are installed properly.

--- bill