RSS

Arduino LCD

16 Mar

LCD_1602LCD

I got this LCD from ebay yesterday, tried it with this simple code below:

Parts:

Sample code 1:

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

void setup()
{
    lcd.begin(16,2);
    lcd.backlight();
    lcd.setCursor(0, 0);
    lcd.print("Hello world!");
    lcd.setCursor(0, 1);
    lcd.print("Row number: ");
    lcd.setCursor(12, 1);
    lcd.print("2");
}
void loop()
{

}

Sample code 2:

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

void setup()
{
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0, 0);        //First column, first row
lcd.print("Hello world!");
lcd.setCursor(0, 1);        //First column, second row
lcd.print("Row number: ");
lcd.setCursor(12, 1);       //12th column, second row
lcd.print("2");
lcd.blink();                //start blinking cursor
delay (3000);               //delay 3 seconds
}
void loop()
{
demoDisplay();
}
void demoDisplay()
{
lcd.clear();              // clear display, set cursor position to zero
lcd.setBacklight(HIGH);        // Backlight on
lcd.setCursor (0,0);           //col 0 of line 1
lcd.print("Boot sequence");
lcd.setCursor (0,1);           // go col 0 of line 2
lcd.print("starting.");
lcd.noBlink();                 //stop blinking cursor
delay(1000);                   //delay 1 second
wipeLines();                   //run function wipeLines
}

void wipeLines() {
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 20; x++) {
lcd.setCursor (x,y);
lcd.print(" ");
delay(10);
}
}
}
About these ads
 
23 Comments

Posted by on 16 March, 2013 in code, Hardware

 

Tags: , , ,

23 responses to “Arduino LCD

  1. bob

    6 April, 2013 at 07:23

    Did it work? Both code examples are for a 4-bit interface, not I2C. Do they compile?

     
    • magnar81

      8 April, 2013 at 09:15

      Yes i works, all code i post here is tested.
      I bought this from ebay and it is one of those where they have got an I2C I/O expander chip
      and wired it to the LCD in 4-bit mode.

       
  2. Paul H

    17 May, 2013 at 06:44

    I got an error “sketch_may18b:3: error: ‘POSITIVE’ was not declared in this scope”. May I ask what value should be POSITIVE?

     
    • magnar81

      18 May, 2013 at 07:03

      Hi Paul,

      Are you trying to compile this exact code or have you changed it?
      What version of arduino software are you using? And last, have you the correct LiquidCrystal_I2C library ?

       
  3. Paul H

    19 May, 2013 at 04:01

    I find another library, it works now. Thanks.

     
    • Helio Reis

      3 June, 2013 at 02:35

      Paul H where do you find the other library?
      Please send me any info.

       
      • magnar81

        3 June, 2013 at 02:38

        Have you tried my link to the Library? You should also remove all the other LCD library from the folder.

         
      • Ana Clara

        27 May, 2014 at 03:08

        errror :

        LiquidCrystal_I2C\LiquidCrystal_I2C.cpp.o: In function `LiquidCrystal_I2C’:
        C:\Users\anaclara\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.cpp:28: multiple definition of `LiquidCrystal_I2C::LiquidCrystal_I2C(unsigned char, unsigned char, unsigned char)’
        LiquidCrystal_I2C\LiquidCrystal_I2C.cpp.o:C:\Users\anaclara\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.cpp:28: first defined here

        what i do ?

         
  4. Helio Reis

    3 June, 2013 at 03:51

    Yes magnar81, i’ve already tried with your library, and deletec the original LDC library folder, and also tried with arduino 0022, 0023, and 1.05. And allways had the same problem.
    “sketch_may18b:3: error: ‘POSITIVE’ was not declared in this scope”

     
  5. Ionass

    6 July, 2013 at 06:35

    same problem : “POSITIVE was not declared in this scope ” . I’ve removed all previous libraries , and installed the one i’ve downloaded from this site ….but no luck . What the hell can i do to get this lcd working ?

     
  6. magnar81

    10 July, 2013 at 02:35

    For you who had problems with this code, do you have the below lines at the begining of the code?
    #include
    #include

     
  7. tizen

    26 July, 2013 at 01:19

    same for me “POSITIVE was not declared in this scope ”

     
  8. tizen

    26 July, 2013 at 05:03

    IT WORKS WITH THE LIBRARY V 1.2.1 DOWNLOAD FROM

    https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

     
  9. Moff

    2 November, 2013 at 04:47

    It works with the library provided (the second one – http://magnusglad.se/LiquidCrystal_I2C.rar)
    I just kept reading the errors and loading the libraries from the .rar file one at a time, as indicated by the error information. By the time I was done, the #included libraries looked like this:

    #include
    #include
    #include
    #include

    Hope that helps someone!

    Thanks for the guide magnar81, got my ebay LCD working great!

     
    • Will

      9 November, 2013 at 07:31

      i had the same problems while running “hello world” code in library. i have downloaded many different library from the site that you guys provided, but it doesn’t work. please help me make it work!!! many thanks

       
      • Moff

        11 November, 2013 at 07:00

        Why don’t you post your error from the arduino console @Will?
        Also, use the code supplied above, as the code library ‘Hello World’ is for the LCD without the backing chip as mentioned above (I2C I/O expander chip). The interaction (both code and wiring) will be completely different (and easier) with I2C chip as opposed to the 8pin wiring..

         
  10. Moff

    2 November, 2013 at 04:48

    it stripped the important bits!
    #include I2CIO.h
    #include LCD.h
    #include Wire.h
    #include LiquidCrystal_I2C.h

     
  11. Tim P-M

    2 February, 2014 at 09:07

    On my Arduino it came up with: ‘LiquidCrystal_I2C’ does not name a type What do I do?

     
  12. baronrouge

    9 April, 2014 at 09:17

    Worked great for me using magnar81′s 2nd library. Thanks for this, nice work

     
  13. WimW

    1 May, 2014 at 09:47

    It seems to me the IDE is messing up paths. I too have the obnoxious “type does not exist” error. It is the first time I try Arduino again after moving on to Windows 7. My sketches directory is not in My Documents, but on a data-disk. I have tried the library folder copied nearly evertwhere (in sketches-folder, in the project folder, in the program installation folder (where there is a “libraries” too…), but nothing works.

    Only, when I open through the examples menu a sketch from the LiquidCristal library, the libs are found. However, then the sketch directory is somtimes the example folder of the library on C: (installation), sometimes a copy in docs and settings appears.

    Arduino 1.0.5 R2 – I am going to try an older version, for this looks rather buggy.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: