LCD 1602 not displaying.

Hi all! I am a beginner and am experiencing display problems with my LCD 1602. I uploaded my sketch (mentioned below) onto the board and it is not displaying it. I have a Mega 2560 board and there were no other errors. I'm following this guide: https://create.arduino.cc/projecthub/joshi/settlers-of-catan-dice-d653f0

Also, how do you connect a button onto the setup?

The code looks like this:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int diceButton = 10;
int reply;

int count = 0;

long diceOne;
long diceTwo;

void setup() {
  lcd.begin(16, 2);
  pinMode(diceButton, INPUT);
  randomSeed(analogRead(0));
  lcd.setCursor(1, 0);
  lcd.print("Roll the dice!");
}

void buildUp() {
  lcd.clear();
  int countDelay = 220;
  int setColumn = 0;
  for (count = 0; count <= 16; count++) {
    lcd.setCursor(setColumn, 0);
    lcd.print(random(1, 7));
    lcd.setCursor(setColumn, 1);
    lcd.print(random(1, 7));
    delay(countDelay);
    countDelay -= 13;
    setColumn += 1;
  }
}

void loop() {
  diceButton = digitalRead(10);
  diceOne = random(1, 7);
  diceTwo = random(1, 7);

  if (diceButton == HIGH) {
    buildUp();
    lcd.clear();
    lcd.setCursor(7, 0);
    lcd.print(diceOne);
    lcd.setCursor(7, 1);
    lcd.print(diceTwo);

    if (diceOne + diceTwo == 7) {
      lcd.clear();
      lcd.setCursor(7, 0);
      lcd.print("7");
      lcd.setCursor(3, 1);
      lcd.print("The Robber");
    }
  }
}

Thank you in advance!

settlers_of_catan_dice_code.ino (1.02 KB)

See Troubleshooting on LCD I2C

I don't have an I2C

Try to adjust the contrast of LCD by rotating potentiometer

No results. I think I have to do something with a button, as mentioned in the tutorial, but no port was given so I did not do it.

OK, now please read the instructions for posting so you can edit your first post and show the code in the text for us to inspect.

Also, please clarify what "it is not displaying it" means. It may not be doing what you wanted it to, but what is the display doing? Does it light up? Does it show anything?

Do you understand what the contrast control does? (By the way, do not connect the contrast control to 5 V - leave that end unconnected or even better for a 10k pot, connect it back to ground. This is a very long-standing design blunder that people have mindlessly copied. :roll_eyes: )

Waiting for progress before I say more ... :grinning:

Oh yes, have you actually connected the display? People sometimes imagine that resting the display on a pin header without soldering it will magically connect it.

Let's have a photo, taken in outside daylight with perfect focus, at least two megapixels, not in a dark room. :astonished:

So, I have the 10k potentiometer connected to VD and it is showing the 16 bars on the first row, whose brightness is dependent on the amount of energy going through the pot.

Here's what it looks like:

Sorry, it is currently night for me, that is the best I can do right now.

Wait, I just figured it out, I don't know what I did though, but now it is displaying random stuff like: 0,o,?,!,etc.

Hi, I am new to Arduino and am following this "Settlers of Catan" dice tutorial:

https://create.arduino.cc/projecthub/joshi/settlers-of-catan-dice-d653f0

I don't know how to connect the button to the board as no pin header number is mentioned.

I have a Mega 2560 board.

Here is the sketch:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int diceButton = 10;
int reply;

int count = 0;

long diceOne;
long diceTwo;

void setup() {
  lcd.begin(16, 2);
  pinMode(diceButton, INPUT);
  randomSeed(analogRead(0));
  lcd.setCursor(1, 0);
  lcd.print("Roll the dice!");
}

void buildUp() {
  lcd.clear();
  int countDelay = 220;
  int setColumn = 0;
  for (count = 0; count <= 16; count++) {
    lcd.setCursor(setColumn, 0);
    lcd.print(random(1, 7));
    lcd.setCursor(setColumn, 1);
    lcd.print(random(1, 7));
    delay(countDelay);
    countDelay -= 13;
    setColumn += 1;
  }
}

void loop() {
  diceButton = digitalRead(10);
  diceOne = random(1, 7);
  diceTwo = random(1, 7);

  if (diceButton == HIGH) {
    buildUp();
    lcd.clear();
    lcd.setCursor(7, 0);
    lcd.print(diceOne);
    lcd.setCursor(7, 1);
    lcd.print(diceTwo);

    if (diceOne + diceTwo == 7) {
      lcd.clear();
      lcd.setCursor(7, 0);
      lcd.print("7");
      lcd.setCursor(3, 1);
      lcd.print("The Robber");
    }
  }
}

Thank you in advance. (link for sketch also mentioned below)

settlers_of_catan_dice_code.ino (1.02 KB)

int diceButton = 10;

The button connects pin 10 to +5 Volts. There is a 10K pulldown resistor between ground and pin 10.

You shure that R/W pin is connected to Ground? And using D4 - D7 pins...


Wow!

That is an amazingly clear picture. With nicely soldered header pins.

So I gather it is not your display. :astonished:

This display tells you the power connections to the backlight (16, 15) are working so the backlight is on, the power connections to the LCD (pins 1 and 2) are correct and the contrast (pin 3) is correctly set.

What is not working is the code on the Arduino controlling the display so either the code is wrong or the connections to pins 4,5,6 and 11 to 14 are not correct.

Topics on the same project merged