Problem with I2C-Interface on LCD Displays

Hi Community :slight_smile: ,

I have a big Problem with my Arduino Uno and my 16 x 2 LCD Display.
Everytime I try to compile my Code, I always get the same Error.
I tried EVERYTHING! NOTHING worked! :’(

Always I get this Error:

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr5/crtm328p.o:(.init9+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status

I use this Sketch:

/*
** Example Arduino sketch for SainSmart I2C LCD Screen 16x2
** based on https://bitbucket.org/celem/sainsmart-i2c-lcd/src/3adf8e0d2443/sainlcdtest.ino
** by
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)

** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal 

** Modified - Ian Brennan ianbren at hotmail.com 23-10-2012 to support Tutorial posted to Arduino.cc

** Written for and tested with Arduino 1.0
**
** NOTE: Tested on Arduino Uno whose I2C pins are A4==SDA, A5==SCL

*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x27 // <<----- Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;

LiquidCrystal_I2C	lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
 lcd.begin (16,2); //  <<----- My LCD was 16x2

 
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home

 lcd.print("Hello World!");  
}

void loop()
{
 // Backlight on/off every 3 seconds
 lcd.setCursor (0,1);        // go to start of 2nd line
 lcd.print(n++,DEC);
 lcd.setBacklight(LOW);      // Backlight off
 delay(3000);
 lcd.setBacklight(HIGH);     // Backlight on
 delay(3000);
}

I also use F Malpartida’s Liquid Crystal 1.2.1 Library and Version 1.6.3 of the Arduino Software.

LG Lukas

I tried EVERYTHING! NOTHING worked!

Which of the many other threads with the terms I2C and LCD in the title have you looked at? Specifically have you looked at this zombie thread (it refuses to die)? It’s last resurrection was this morning.

Don

floresta: Specifically have you looked at this zombie thread (it refuses to die)? It's last resurrection was this morning.

Actually, it probably should be a "sticky". :grinning:

Oh my god it works! :)

I just tried to reinstall the Wire.h and voilá: It works! :D :D :D :D :D :D :D :D :D :D :D :D :D :D

But many thanks for helping me !

LG