RESOLVED!! - Stock LCD code errors out

I’m using the stock “Hello world” code and it doesn’t want to work.
I check the code and it gives the error at the bottom

Here’s the code (using the built in example codes)

/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// 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);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

and here’s the error list at the bottom

HelloWorld:99: error: redefinition of ‘LiquidCrystal lcd’
HelloWorld:41: error: ‘LiquidCrystal lcd’ previously declared here
HelloWorld.cpp: In function ‘void setup()’:
HelloWorld:101: error: redefinition of ‘void setup()’
HelloWorld:43: error: ‘void setup()’ previously defined here
HelloWorld.cpp: In function ‘void loop()’:
HelloWorld:108: error: redefinition of ‘void loop()’
HelloWorld:50: error: ‘void loop()’ previously defined here

Any idea why the stock example code won’t work?

Have you got two tabs?

(This isn't an installation and troubleshooting question, so I moved it)

By two tabs, you mean I should have a tab with the LiquidDisplay as the header?

No, the second tab didn't open but I haven't done any Arduino stuff in a while so didn't know if things have changed.

Last time I saw someone with an error like that, there was a 2nd copy of the sketch file in the same folder, with the name “<sketch_name> (copy).ino”

The Arduino IDE doesn’t seem to handle spaces in file names properly, and will not open a 2nd tab for the 2nd file, but will read it during compile and generate numerous error messages.

I don’t have any filenames with spaces. In the directory I only have 3 sketch files total.

Counter1 (first version of counter)
Counter2 (different type of counter
sketch_Counter1 (first prototype sketch with lots of errors)
sketch_feb02c (sketch to find address of I2C board)

The current sketch is Counter1

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);  // set the LCD address to 0x27 for a 16 chars and 2 line display


// this constant won't change:
const int  Up_buttonPin   = 2;    // the pin that the pushbutton is attached to
const int  Down_buttonPin = 3;

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int up_buttonState = 0;         // current state of the up button
int up_lastButtonState = 0;     // previous state of the up button

int down_buttonState = 0;         // current state of the up button
int down_lastButtonState = 0;     // previous state of the up button
bool bPress = false;

void setup()
{
  Serial.begin(9600);
  pinMode( Up_buttonPin , INPUT_PULLUP);
  pinMode( Down_buttonPin , INPUT_PULLUP);
 
   lcd.init();                      // initialize the lcd
  // lcd.begin();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Please Select:");
  lcd.setCursor(2,1);
  lcd.print(buttonPushCounter);
 
}


void loop()
{
   checkUp();
   checkDown();

   if( bPress){
       bPress = false;
      lcd.setCursor(2,1);
      lcd.print("               ");
      lcd.setCursor(2,1);
      lcd.print(buttonPushCounter);
   }
  
}

void checkUp()
{
  up_buttonState = digitalRead(Up_buttonPin);

  // compare the buttonState to its previous state
  if (up_buttonState != up_lastButtonState) {
    // if the state has changed, increment the counter
    if (up_buttonState == LOW) {
        bPress = true;
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes: ");
      Serial.println(buttonPushCounter);
    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  up_lastButtonState = up_buttonState;
}
void checkDown()
{
  down_buttonState = digitalRead(Down_buttonPin);

  // compare the buttonState to its previous state
  if (down_buttonState != down_lastButtonState) {
    // if the state has changed, increment the counter
    if (down_buttonState == LOW) {
        bPress = true;
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter--;
     
      Serial.println("on");
      Serial.print("number of button pushes: ");
      Serial.println(buttonPushCounter);
    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  down_lastButtonState = down_buttonState;
}

I’ve determined that the address of the I2C is 0x27 so that shouldn’t be the problem.

I’ve managed to get simple codes working, like “blink”.

When I upload this code I get no error codes.

When I upload the sketch “Counter1” I get nothing on the LCD except the backlight.

I’ve tried this on two different LCDs with the same results, or lack thereof.

This is very frustrating.

(there is only one tab on the sketch)

NEVERMIND

I feel so stupid!!

The LCD brightness was all the way up so the display just wasn't showing.

DUMB!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

No, that does not account for a compiler error.

AWOL:
No, that does not account for a compiler error.

Ah, the original compiler error was solved by downloading a more current version of the Arduino IDE.
It had a few extra tabs that my old one didn’t have. One of the tabs was for the “old bootloader” for the Arduino Nano ATmega 238P.

I also needed to fix a library issue for the LiquidCrystal_I2C.h
I had Arduino in 2 locations on my laptop and even though it showed the library, it didn’t seem to reference it.

Once I installed the new IDE and imported the library, checked the address of the LiquidCrystal_I2C, and set all the correct data, I was actually uploading just fine. I just couldn’t see the display. I thought it was showing blank.

Now I have the working device I needed. I might still tweak the code a little but it’s working fine.