Arduino Forum

Products => The Arduino Starter Kit and Basic Kit => Topic started by: edwardsamoy on Dec 11, 2015, 08:21 pm

Title: project 11 lcd problem
Post by: edwardsamoy on Dec 11, 2015, 08:21 pm
my lcd screen only lights up
but doesn't display anything
what's wrong?

my code:
#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() {
  pinMode(switchPin,INPUT);
  lcd.begin(16,2);
  lcd.print("vraag maar!");
  lcd.setCursor(0,1);
  lcd.print("ik weet alles");
}

void loop() {
  switchState = digitalRead(switchPin);
  if(switchState != prevSwitchState){
    if(switchState == LOW){
      reply = random(8);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("de arduino zegt:");
      lcd.setCursor(0,1);
      switch(reply){
        case 0:
          lcd.print("ja");
        break;
        case 1:
          lcd.print("nee");
        break;
        case 2:
          lcd.print("waarschijnlijk");
        break;
        case 3:
          lcd.print("natuurlijk");
        break;
        case 4:
          lcd.print("onzeker");
        break;
        case 5:
          lcd.print("vraag opnieuw");
        break;
        case 6:
          lcd.print("dommerik");
        break;
        case 7:
          lcd.print("hahaha");
        break;
      }
    }
  }
  prevSwitchState = switchState;
}
Title: Re: project 11 lcd problem
Post by: dannable on Dec 11, 2015, 11:08 pm
More than likely you have made an error in the wiring.

How do you get the smiley face in your sketch?

Please read and digest this (http://forum.arduino.cc/index.php?topic=148850.0) post.
Title: Re: project 11 lcd problem
Post by: edwardsamoy on Dec 12, 2015, 06:42 pm
the smiley comes from "8)"
i didnt wanted to do that
Title: Re: project 11 lcd problem
Post by: prince_x2 on Dec 21, 2015, 11:44 am
@dannable! That is:
reply=random( 8 );
without spaces, as 8 ) with spaces will make it smiley 8)
Title: Re: project 11 lcd problem
Post by: dannable on Dec 21, 2015, 12:20 pm
@prince_x2

I am perfectly well aware of how the smiley got into the OP's code. If they had the read the post 'How to use this forum' they would have learnt how to post code correctly. The smiley proved that they hadn't bothered to read it.