Go Down

Topic: Project 11 - Crystal Ball lcd issue (Read 7159 times) previous topic - next topic

meteoros

Hi,i've some weird charaters in the lcd,how can i fix it?(check image)thanks

2fjeff

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.

meteoros

Now I dont have enough light to take a picture,tomorrow morning i'll do it.Thanks

meteoros

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

janvier123


geoboi18

were you able to figure out what the problem was?

Gameplayer11

#6
Dec 25, 2016, 11:18 am Last Edit: Dec 25, 2016, 11:25 am by Gameplayer11
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 :)

oqibidipo


Go Up