Go Down

Topic: project 11 lcd problem (Read 1 time) previous topic - next topic

edwardsamoy

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

dannable

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 post.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

edwardsamoy

the smiley comes from "8)"
i didnt wanted to do that

prince_x2

#3
Dec 21, 2015, 11:44 am Last Edit: Dec 21, 2015, 11:50 am by prince_x2
@dannable! That is:
reply=random( 8 );
without spaces, as 8 ) with spaces will make it smiley 8)

dannable

@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.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Go Up