lcd was not declared in this scope, but the same function has passed inspection

Doing a project that came with the basic kit. A command is not compiling but the same command was ok before.

#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("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(“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;
}

And the error is just ‘lcd’ is not declared in this scope.
I underlined the problem line

#include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2);

This isn’t valid C. It should be two lines.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);

Pete

Also, please read Nick Gammon's How To post at the top of this Forum on the proper way to post code here using code tag. Also, use Ctrl-T to format it to a common C style before you post it. You can edit our original post and add code tags. It will help us help you.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: