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 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, 5V, GND, DAT, CLK, 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".
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);
Text editor powered by tinymce.