Problem with the LCM1602C using the UNO

Hello,

I am having problems with the LCM1602C using the Arduino UNO.
I was doing the Crystal Ball project from the projects book and came across this error where the characters on the screen are malformed or there are lines going through them. I have attached the picture of it, if you need a better pic of the wiring just ask.
I am using the example code for the Crystal Ball.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// set up a constant for the tilt switchPin
const int switchPin = 6;

// variable to hold the value of the switchPin
int switchState = 0;

// variable to hold previous value of the switchpin
int prevSwitchState = 0;

// a variable to choose which reply from the crystal ball
int reply;

void setup() {
  // set up the number of columns and rows on the LCD 
  lcd.begin(16, 2);
  
  // set up the switch pin as an input
  pinMode(switchPin,INPUT);
  
  // Print a message to the LCD.
  lcd.print("Ask the");
  // set the cursor to column 0, line 1
  // line 1 is the second row, since counting begins with 0
  lcd.setCursor(0, 1);
  // print to the second line
  lcd.print("Crystal Ball!");
}

void loop() {
  // check the status of the switch
  switchState = digitalRead(switchPin);

  // compare the switchState to its previous state
  if (switchState != prevSwitchState) {
    // if the state has changed from HIGH to LOW
    // you know that the ball has been tilted from 
    // one direction to the other 
    if (switchState == LOW) {
      // randomly chose a reply
      reply = random(8);
      // clean up the screen before printing a new reply
      lcd.clear();
      // set the cursor to column 0, line 0     
      lcd.setCursor(0, 0);
      // print some text
      lcd.print("the ball says:");
      // move the cursor to the second line
      lcd.setCursor(0, 1);

      // choose a saying to print baed on the value in reply 
      switch(reply){
      case 0:
        lcd.print("Yes");
        break;

      case 1:
        lcd.print("Most likely");
        break;

      case 2:
        lcd.print("Certainly");
        break;

      case 3:
        lcd.print("Outlook good");
        break;

      case 4:
        lcd.print("Unsure");
        break;

      case 5:
        lcd.print("Ask again");
        break;

      case 6:
        lcd.print("Doubtful");
        break;

      case 7:
        lcd.print("No");
        break;
      }
    }
  }
  // save the current switch state as the last state 
  prevSwitchState = switchState;
}

As you can see from the image i have attached the characters are being displayed but they are not displayed correctly.

Any help is much appreciated.

The display is evidently faulty. This is reported frequently here. Try carefully pressing around the mounting bezel and see if it changes.

Am I missing something? I don't see any image.

I have never seen an Arduino projects book and my crystal ball doesn't know anything about the one to which you are referring.

Has your LCD ever worked properly? Any time you are having trouble with a strange display on your LCD you should try running a 'static' sketch, one where loop() is empty. Here's an example:

#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

void setup()
  {
  lcd.begin(16, 2);                          // put your LCD parameters here
  lcd.print("hello, world!");
  lcd.setCursor(0,1);
  lcd.print("it works!");
  }

void loop()
  {
  }

Don

floresta:
Am I missing something? I don't see any image.

It was there, edited away somehow.
Contrast and backlight correct, vertical bars superposed on each (or most) characters.

Or at least that is what I thought. OK, I grant that the code posted is faulty with no debounce function for an input device which is guaranteed to generate intense contact bounce. In this case, a simple delay(100) would sort that out tolerably well.

If it was flickering (with no movement of the ball), then a code fault is the better answer, if it was static, then the display is faulty. Should indeed, patch the code first though.

{Hey - the Draft recovery works! I like it!}