Hi there,
First off, I'm new to Arduino... so try to be nice! ![]()
I'm writing a program that involves the use of a LCD display. Up until this point my code was compiling fine -- or with errors easy enough to fix. But now I'm stumped.
The compiler is spitting out errors for most (but not all) of the times I use lcd.setCursor. Also in my setup, it gives me an error for the lcd.begin function. Weirdly, the compiler does not have an issue with lcd.print--- maybe because I always use it after I use lcd.setCursor? Before you say anything, yes, I am including LiquidCrystal.h.
The error is always this:
error: 'lcd' was not declared in this scope
I don't want to make this too lengthy of a post, so I will just include 2 examples. If you want any more examples, just ask.
Example 1:
void setup() {
// initializing pins
pinMode( BUTTON_ADC_PIN, INPUT );
digitalWrite( BUTTON_ADC_PIN, LOW );
digitalWrite( LCD_BACKLIGHT_PIN, HIGH );
pinMode( LCD_BACKLIGHT_PIN, OUTPUT );
lcd.begin( 16, 2 ); // I get an error here
lcd.setCursor( 0, 0 ); // No error here
lcd.print( "Select a user: " ); // No error here
lcd.setCursor( 0, 1 ); // No error here
lcd.print( "BLUE purple red" ); // No error here
}
Example 2:
void userPrint(int user){
if ( user = 0 ){
lcd.setCursor( 0, 1 ); // Error here
lcd.print( "BLUE purple red " ); // No error here
}
else if( user = 1 ){
lcd.setCursor( 0, 1 ); // Error here
lcd.print( "blue PURPLE red " ); // No error here
}
else {
lcd.setCursor( 0,1 ); // Error here
lcd.print( "blue purple RED "); // No error here
}
}
Thanks for reading. If you have any ideas as to what the issue is, feel free to respond. ![]()
I'm sure this must be a very simple mistake.