Getting error when I try to use lcd.setCursor or lcd.begin

Hi there,
First off, I'm new to Arduino... so try to be nice! :stuck_out_tongue:
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. :slight_smile:
I'm sure this must be a very simple mistake.

Post your entire code.
List your specific LCD model might help.

this might be important.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Have you #included the LCD library ?
Have you created an instance of the LCD named lcd ?

I took out the personal information (phone number, username, etc) out of this code. I've attached the code to this post.

My LCD shield is this one:

LaundryRoom2.ino (8.86 KB)

bangs head on desk

I accidentally deleted the pin initialization line.
Well played, self.
Thank you so much!