Arduino Forum

Products => The Arduino Starter Kit and Basic Kit => Topic started by: meteoros on Feb 08, 2015, 02:51 pm

Title: Project 11 - Crystal Ball lcd issue
Post by: meteoros on Feb 08, 2015, 02:51 pm
Hi,i've some weird charaters in the lcd,how can i fix it?(check image)thanks
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: 2fjeff on Feb 08, 2015, 09:49 pm
It is a little difficult to see in the photo, but it looks to me that you have pin 1 of the LCD  display (Vss) connected to 5v on the breadboard, when it should be connected to ground, and pin 2 of the LCD (Vcc) should be connected to 5v on the breadboard.
Also make sure you have the breadboard ground connected to the arduino board ground pin, and everything grounded properly, otherwise the arduino will send all kinds of crazy data, that will just be gibberish.

Please post to let me know if this fixed the problem.
If not please post a photo showing all connections both on the breadboard and the arduino and a copy of the code.
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: meteoros on Feb 09, 2015, 02:12 am
Now I dont have enough light to take a picture,tomorrow morning i'll do it.Thanks
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: meteoros on Feb 09, 2015, 02:18 pm
Code: [Select]
#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() {
  // put your setup code here, to run once:
  lcd.begin(16,2);
  pinMode(switchPin,INPUT);
 
  lcd.print("Ask the");
  lcd.setCursor(0,1);
  lcd.print("Crystal Ball!");
 
}

void loop() {
  // put your main code here, to run repeatedly:
  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;
 
}
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: janvier123 on Mar 26, 2015, 01:11 pm
picture of the issue?

Thx
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: geoboi18 on Mar 16, 2016, 08:24 am
were you able to figure out what the problem was?
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: Gameplayer11 on Dec 25, 2016, 11:18 am
wth is my problem?!?!?
the error says:

exit status 1
'prevSwitchState' was not declared in this scope
 
and my script is:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2)
; const int switchPin = 6;
int switchState = 0;
int prewSwitchState = 0;
int reply;
void setup() {
  lcd.setCursor(0, 1);
  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 //ignore this empty space);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("The bal 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("Maybe...")
          break;
        case 4;
          lcd.print("Unsure")
          break;
        case 5;
          lcd.print("Ask again");
          break;
        case 6;
          lcd.print("Doubtful");
          break;
        case 7;
          lcd.print("Nope.");
          break;

      }
    }
  }
  prevSwitchState = switchState;

}
 


I dont understand what is the problem pls anyone help me
Thanks :)
Title: Re: Project 11 - Crystal Ball lcd issue
Post by: oqibidipo on Dec 25, 2016, 01:50 pm
int prewSwitchState = 0;