Another option for connecting is to use SPI, which is a simpler protocol. The good news about SPI is that its very simple and you can use any 3 pins to connect. You can share the data and clock pins with another device as long as they remain outputs, the latch pin should only be used for the backpack. So if you wanted 3 LCDs, for example, they would all have the same data and clock pins, but the latch pin would be different, for 5 pins total

This library does not use the Hardware SPI library, which means you can use any 3 pins! However, if you are using the hardware SPI port (such as for Ethernet, WiFi, an LCD, etc. etc) you cannot share those pins with this LCD!
The first thing you will need to do is to enable SPI. To do this, solder the SPI Enable solder jumper by heating up the pads with a soldering iron and soldering a blob onto both pins:

This will switch the backpack over to SPI mode instead of I2C. If you want to go back to I2C, use wick or a solder sucker to remove the jumper

Next we will connect 5 wires, 5VGNDDATCLK, and LAT.

  • To match the example, CLK goes to to Digital 2
  • DAT to Digital 3,
  • LAT to Digital 4

Once we have the example sketch running you can of course change these to anything you'd like

  • Connect 5V and GND to the 5v and Ground Arduino power pins. If you are using a 3.3V Arduino, you still need to power the LCD with 5V power! You can use 3.3V logic just fine

Install Adafruit_LiquidCrystal

To begin reading sensor data, you will need to use the Adafruit_LiquidCrystal library.. You can install the Adafruit_LiquidCrystal library for Arduino using the Library Manager in the Arduino IDE.

Click the Manage Libraries ... menu item, search for Adafruit LiquidCrystal and select the Adafruit LiquidCrystal library:

If asked about any dependencies, click "Install All".

Load Demo

Restart the IDE and load up the Adafruit_LiquidCrystal->HelloWorld_SPI demo

Upload the sketch. You should see the backlight turn on when the Arduino resets. If you don't see any characters, adjust the Contrast trim potentiometer with a mini-screwdriver until you see the text clearly

The default HelloWorld sketch blinks the backlight as well as updating the text.

If you see the backlight blinking that means your connection to the SPI port is OK but the contrast is too low or too high, or the LCD data pins are not solidly connected.

Check the contrast first by gently twisting the mini trim potentiometer, if that doesn't help, recheck your soldering and resolder all 16 of the LCD pins!

Once you're done, you can remove the blinking LED backlight code:

lcd.setBacklight(HIGH);
delay(500);
lcd.setBacklight(LOW);
delay(500);

This guide was first published on Aug 27, 2012. It was last updated on Feb 24, 2023.

This page (Arduino SPI Use) was last updated on Aug 27, 2012.

Text editor powered by tinymce.