LCD with Sensor Shield v5.0

Hello everyone, I have an Arduino MEGA 2560 and a Sainsmart Sensor Shield v5.0 along with the Sainsmart 2004LCD screen. Whenever I type out code on a new sketch and upload it to the board, nothing happens and I have blocks on the LCD screen.

A picture of my setup:

My code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(11, 13, 12, 7, 6, 5, 4, 3, 2, 1, 0);

void setup()
  lcd.begin(20, 4);

void loop() {}

Your LCD appears to have an I2C adapter. This means that you cannot use the regular LiquidCrystal library that comes with the Arduino IDE.

Have you considered trying the example code on the Sainsmart web page?


I think you have two problems.

  1. Your display is clearly running on an I2C adapter. It therefore requires a different library and a slight change to the code. The library is probably LiquidCrystal_I2C2004V1 and it includes a workling example.

  2. You appear to have correctly wired the LCD to the shield, but the shield is made for Uno, not Mega, and, as it stands, the LCD is not connected to the I2C bus. I2C on Mega is pins 20,21, not A4,A5, as is clearly marked in your picture. You may find there is provision on the shield to run a jumper to these pins. Failing that, a bit of butchery on the shield is in order.