LCD in Starter Kit Displaying Weird Characters

Hello!

I have purchased the Arduino Starter Kit and I am currently putting together the “Crystal Ball” project having done all of the ones previous to this project. Everything seems to be working except for the fact that the LCD is displaying odd characters. The potentiometer is a little shaky but if it is loose I push it in a little further and I can indeed adjust the contrast of the screen. The tilt switch is also shaky but I guess that’s the point of it. When I shake the setup, the screen does scramble the alien characters.

I have checked my wiring over and over again, countless times, and even rewired the thing into different slots in the breadboard. I have downloaded LiquidCrystal 1.0 library and the same thing happens. I have already searched in this forum however I found that a lot of people talk about displaying blocks rather than alien characters. Please advice!!

LCD Vss → GND
LCD VCC → 5V
LCD Vo → potentiometer
LCD RS → pin 12
LCD R/W → GND
LCD D4 → pin 5
LCD D5 → pin 4
LCD D6 → pin 3
LCD D7 → pin 2
LCD LED+ ->resistor → 5V
LCD LED- → GND

I also tried “Hello, World!” and only these alien characters show up…

Please help!

I have purchased the Arduino Starter Kit and I am currently putting together the "Crystal Ball" project having done all of the ones previous to this project.

This is the second "Crystal Ball" project to show up this week. Unfortunately since I don't have a crystal ball myself I have no idea whatsoever what that project is about.

Everything seems to be working except for the fact that the LCD is displaying odd characters.

What characters are you expecting to see?

The potentiometer is a little shaky but if it is loose I push it in a little further and I can indeed adjust the contrast of the screen.

Any loose connections will wreak havoc with your LCD display.

Don

OK - I found the code on github https://github.com/arduino/Arduino/blob/master/build/shared/examples/10.StarterKit/p11_CrystalBall/p11_CrystalBall.ino and it could use some work.

The code would be better if, in loop(), it didn’t continually clear the display and then rewrite the same information back to line 1.

Try something like this:

  • Put a delay at the end of what is currently in setup()
  • Move the code that prints “the ball says” to setup(), after the newly added delay. Also move the second ‘setCursor’ statement.
  • Pad each of the possible replies so they are all the same length.

New code (untested):
EDIT: Sorry about the poor formatting - this is my first shot at using the horrible code editor in the recently botched up forum software.

// 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!");

delay (2000);

// 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);
}

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);

// choose a saying to print based 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;
}

Don

Hi Don,

Thank you so much for looking into this! I tested all of my wires again and rewired the entire thing and now it seems to be working! Thanks for pointing out that it may be the connection, I just needed someone to pinpoint it to that.

A

floresta:
OK - I found the code on github https://github.com/arduino/Arduino/blob/master/build/shared/examples/10.StarterKit/p11_CrystalBall/p11_CrystalBall.ino and it could use some work.

The code would be better if, in loop(), it didn’t continually clear the display and then rewrite the same information back to line 1.

Try something like this:

  • Put a delay at the end of what is currently in setup()
  • Move the code that prints “the ball says” to setup(), after the newly added delay. Also move the second ‘setCursor’ statement.
  • Pad each of the possible replies so they are all the same length.

New code (untested):
EDIT: Sorry about the poor formatting - this is my first shot at using the horrible code editor in the recently botched up forum software.

// 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!”);

delay (2000);

// 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);
}

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);

// choose a saying to print based 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;
}




Don