Need Help with My Arduino Crystal Ball Project - Weird Yellow Squares on Display

Hey everyone,

I'm working on the Arduino Crystal Ball project where it's supposed to act like a magic crystal ball. But there's a problem. Every time I turn it on, instead of showing cool messages, all I get are these yellow squares on the bottom row of the screen. I think there might be something wrong with my code or maybe how I hooked everything up.

Here's the code I'm using:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2, 1);
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("Frog in my soup!");
        break;
        case 1:
        lcd.print("Oops, wrong chat!");
        break;
        case 2:
        lcd.print("Not my circus!");
        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;
}



If anyone can help me figure out why it's not working and how to fix it, that would be awesome. I really want to get this project working properly.

Thanks!

-3Konverts

Why do you have seven inputs in the LCD opening statement:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2, 1);
The standard is six, i.e.
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Perhaps you just need to delet the ", 1" from the opening statement?

Yes, if it's the same project #11 Crystal Ball:

LiquidCrystal lcd(12,11,5,4,3,2); // generates an instance in the lcd

a7

It works now, thank you for your help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.