I too am having a problem with Project 10: Crystal Ball. I saw the post by @neulad from Dec 9 for the same issue. That problem was a result of soldering between DB4 and DB5. I've checked the points on my lcd board and I don't see the same issue.
I've changed the wiring several times and compared it to the book and to an Arduino video to make sure I have the right arrangement. I've also checked the each wire and made sure they're seated securely. The tilt sensor is also seated firmly. Page 89 of the manual shows a bottom view of the sensor, with pins 1 and 2 being for power and pins 3 and 4 for ground, I've tried rotating the sensor around on the breadboard. But that didn't work either.
I removed the tilt sensor, the wires to the power and ground, and its resistor see if that was causing the problem. That didn’t solve the problem so I put those back on the board.
Here's my coding:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
void setup() {
lcd.begin(16,2);
pinMode(switchPin, INPUT);
lcd.print("Ask the");
lcd.setCursor (0,1);
lcd.print("Crystal Ball!");
}
void loop() {
switchState = digitalRead (switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
reply = random(8);
lcd.clear();
lcd.setCursor (0,0);
lcd.print("The ball says: ");
lcd.setCursor(0,1);
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;
}
}
}
prevSwitchState = switchState;
}
[edit] Disregard ... I just counted the pins and sockets in another photo... you have it right. Are the LCD pins pressed into the breadboard all the way?
From the pictures it looked like you were talking about moving wires, not the POT. And then I got talking with xfpd. So I wasn’t ignoring you, but I see how it could have looked that way. Sorry for the misunderstanding. You were doing your best to help me. Again my apologies.
The video I watched from Arduino on YouTube shows the POT in a different spot so I didn’t think that was the issue. I’m not home right now but I’ll try it as soon as I get back.
The two pins on the left hand side are shown connected to rows 26 and 28 on the breadboard.
Now look at the pin on the right hand side of the potentiometer.
It is shown as being on row 28, the same row as the pin on the left.
This drawing does not match the real life potentiometer, whose right hand pin (the wiper) ends up on row 27. This pin needs to be on row 28 to connect to pin 3 of the LCD display.
To get the wiper to be on row 28, the potentiometer needs to be moved downwards on the drawing, so that the left hand pins are on rows 27 and 29. The wires on the left will need altering too.
It works! Yay! Thanks for the clarification on where the potentiometer needed to go. I forgot that the potentiometer is a transistor and carries current over to the pin on the right side. I also realised I don't understand what each of the pins on the LCD display do, so I need to find some resources on the internet so I read about it.