[SOLVED]Controling 20x4 LCD with Serial interface module

Hello.

I am using this module http://www.ebay.com/itm/131136966439?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649 to control this display TM164ABA pdf, TM164ABA Description, TM164ABA Datasheet, TM164ABA view ::: ALLDATASHEET ::: (datasheet for
TM164ABA but it should be the same).

I tried many libraries and examples but none them is working. I can't even download it to Arduino Due board.
I will soon upgrade which library and code i used to communicate with LCD if needed.

Thanks in advance for any help.

So,

I am using libraries from this website http://arduino-info.wikispaces.com/LCD-Blue-I2C
And code as written in here(version 3) : http://arduino-info.wikispaces.com/LCD-Blue-I2C#v3

The error message looks like this:

Arduino: 1.5.6-r2 (Windows 8), Vývojová deska: "Arduino Due (Programming Port)"

C:\Users\Radovan\SkyDrive\Arduino Moje\libraries\LiquidCrystal\FastIO.cpp: In function 'void fio_shiftOut1(fio_register, fio_bit, uint8_t, boolean)':
C:\Users\Radovan\SkyDrive\Arduino Moje\libraries\LiquidCrystal\FastIO.cpp:214: error: '_BV' was not declared in this scope

Does anybody have an idea how to fix this?

Thank you.

I have a similar if not identical module.

Take a look at this forum thread: --> Arduino i2c for 16x2 lcd no backlight or text after upload [solved] - Displays - Arduino Forum

Don

Well, i looked it up and i think that the guy has problem with backlight.
I want to say that he is at least able to upload the program to arduino.
I am not even able to upload it beacause of mentioned error =(

The thing i can't move with my project, i am stucked right here :frowning:
I am still looking up some more forums, but no effect :-/

Try this library, it is the original LiquidCrystal_I2C library.

LiquidCrystal_I2C.zip (1.07 MB)

Well, i looked it up and i think that the guy has problem with backlight.

Did you look at reply #6 in that thread?

Don

I don't think that you have the library correctly installed.

What is the structure of the folder and the files ? Is the original Liquid Crystal library removed?

When you use the portion of the library

#include <LiquidCrystal_I2C.h>

I do not believe it should be calling FastIO.cpp or FastIO.h which should involve separate # includes.

floresta:

Well, i looked it up and i think that the guy has problem with backlight.

Did you look at reply #6 in that thread?

Don

I did read this post and i tried out your idea. Code here:

/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 Backpack Interface labelled "LCM1602 IIC  A0 A1 A2"
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
//none
/*-----( Declare objects )-----*/
// set the LCD address to 0x20 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address


/*-----( Declare Variables )-----*/
//none

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines and turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on  
  
//-------- Write characters on the display ----------------
// NOTE: Cursor Position: CHAR, LINE) start at 0  
  lcd.setCursor(3,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(2,1);
  lcd.print("From YourDuino");
  delay(1000);  
  lcd.setCursor(0,2);
  lcd.print("20 by 4 Line Display");
  lcd.setCursor(0,3);
  delay(2000);   
  lcd.print("http://YourDuino.com");
  delay(8000);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Start Serial Monitor");
  lcd.setCursor(0,1);
  lcd.print("Type chars 2 display");   


}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }

}/* --(end main loop )-- */


/* ( THE END ) */

Unfortunatelly error appeared:

Arduino: 1.5.7 (Windows 8), Vývojová deska: "Arduino Due (Programming Port)"

C:\Users\Radovan\SkyDrive\Arduino Moje\libraries\LiquidCrystal\FastIO.cpp: In function 'void fio_shiftOut1(fio_register, fio_bit, uint8_t, boolean)':
C:\Users\Radovan\SkyDrive\Arduino Moje\libraries\LiquidCrystal\FastIO.cpp:214:19: error: '_BV' was not declared in this scope
   if(value & _BV(i))
                   ^

I am using libraries from fmalpartida. While using this library i removed the LiquidCrystal library (original) and LiquidCrystal_I2C library from the directory. Printscreeen of directory is attached.
By the way i installed Arduino 1.5.7.

Did i miss something you told me to try or do? :~

You put the library in the wrong place, it needs to go under:

C:\Users*Name*\Documents\Arduino\Libraries

There is a core folder and a sketch folder. The core folder is where you put the library, that is the wrong place to put it. It needs to go into the sketch folder under "libraries" in your MyDocuments.

You put the library in the wrong place, it needs to go under:

C:\Users*Name*\Documents\Arduino\Libraries

Yes, this is the correct place for it. User added libraries go there, and not in C:\Program Files (x86)\Arduino\libraries
which contains the libraries which come with the IDE.

Inside the correct Libraries Folder you should have a folder called Liquid Crystal, and inside that will be Examples, Docs, keywords, and 16 different CPP and H files.

So i checked out how to instal libraries at arduino.cc..... I did it through "Sketch->Import libraries->Add library->library.zip ...
I also double checked if it is in directory as you mentioned C:\Users\Radovan\Documents\Arduino\libraries..........
Then i imported library: Sketch->Import library-> .... and clicked on the name of the library i added.

#include <FastIO.h>
#include <I2CIO.h>
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C_ByVac.h>
#include <LiquidCrystal_SR.h>
#include <LiquidCrystal_SR1W.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>
/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 Backpack Interface labelled "LCM1602 IIC  A0 A1 A2"
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
//none
/*-----( Declare objects )-----*/
// set the LCD address to 0x20 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address


/*-----( Declare Variables )-----*/
//none

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(20, 4);        // initialize the lcd for 20 chars 4 lines and turn on backlight

  // ------- Quick 3 blinks of backlight  -------------
  for (int i = 0; i < 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on

  //-------- Write characters on the display ----------------
  // NOTE: Cursor Position: CHAR, LINE) start at 0
  lcd.setCursor(3, 0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(2, 1);
  lcd.print("From YourDuino");
  delay(1000);
  lcd.setCursor(0, 2);
  lcd.print("20 by 4 Line Display");
  lcd.setCursor(0, 3);
  delay(2000);
  lcd.print("http://YourDuino.com");
  delay(8000);
  // Wait and then tell user they can start the Serial Monitor and type in characters to
  // Display. (Set Serial Monitor option to "No Line Ending")
  lcd.setCursor(0, 0); //Start at character 0 on line 0
  lcd.print("Start Serial Monitor");
  lcd.setCursor(0, 1);
  lcd.print("Type chars 2 display");


}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen6
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }

}/* --(end main loop )-- */


/* ( THE END ) */
Arduino: 1.5.7 (Windows 8), Board: "Arduino Due (Programming Port)"

C:\Users\Radovan\Documents\Arduino\libraries\libraries\fmalpartida-new-liquidcrystal-4ab8294150b5\FastIO.cpp: In function 'void fio_shiftOut1(fio_register, fio_bit, uint8_t, boolean)':
C:\Users\Radovan\Documents\Arduino\libraries\libraries\fmalpartida-new-liquidcrystal-4ab8294150b5\FastIO.cpp:214:19: error: '_BV' was not declared in this scope
   if(value & _BV(i))
                   ^

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

So ehm. I think i did everything right with libraries etc. but it still keep having errors with compiling :-/

Just use

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

You do not need the full library for your sketch. If you were using a parallel lcd you only need to #include<LCD.h>.

I have never used FastIO.h which is causing the compile error. There may be a bug in the library which could be reported or followed up in another thread. See if you can get your lcd working with the limited use of #include. Once you get that far, you can decide what to do.

The following compiles for me so I think you have something else going on.

#include <FastIO.h>
#include <I2CIO.h>
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>

#include<Wire.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly: 
  
}

Perhaps it is the Beta IDE 1.5.7. You might want to use 1.0.5 r2 IDE which should support Windows 8.1. The code I posted above was with 1.05 r2 with Windows 7.

I just reread some earlier posts, and I see you are using a Due, and can't use 1.05r2. If you can isolate the problem to the specific library and IDE you can pursue answers in another thread.

RadoM:
Does anybody have an idea how to fix this?

The issue here is that fm's current library does not work for
ARM based processors, which includes DUE.

The library has many components, many of which you don't need for the i2c interface
but the way this library is packaged and the way the Arduino IDE works all of them have to be compiled
regardless of whether they end up being used or not,
and unfortunately, the pin manipulation code and some of the base LCD class code won't compile on DUE.
Some of the issues are in fm's code and some of the issues are in the core Arduino code that
comes with the IDE.
Some of the issues in fm's code, will not be seen when using i2c and some relate to where the library is installed:
in the core libraries area vs in the sketchbook libraries.
The DUE core code incorrectly defines digitalPinToTimer() and will cause any code that uses it to fail to compile.
fm's code uses this macro so even if you fix the FIO bug, the code will still not compile do to the broken DUE code.
The files included in the Arduino IDE also don't define _BV() which cause some of the code not to compile.

In order to get fm's library working on DUE you will have to edit a few files in the library to work around
the bugs & issues.

First make sure you have the latest version available v1.2.1
Get it from here:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

Edit LiquidCrystal.cpp and add these lines after the inttypes.h include

#undef digitalPinToTimer
#define digitalPinToTimer(_p) NOT_ON_TIMER

This works around the Arduino core code bug of it incorrectly defining digitalPinToTimer()

Edit FastIO.h and these lines after the endif for the #if (Arduino < 100) conditional:

#ifndef _BV
#define _BV(bit) (1 << bit)
#endif

This adds the missing _BV() macro that is missing in the Due core code.

You may still have some compile issues depending on where you installed the library because of the way
this library is bundling so many different device interfaces (library classes) into a single library,
the way the IDE works, and some of the include paths changed on 1.5x vs on 1.x

If you make these changes and are still having issues, report back and I'll walk you through
any other needed fixes.

--- bill

cattledog:
Just use

#include <Wire.h>

#include <LiquidCrystal_I2C.h>




You do not need the full library for your sketch. If you were using a parallel lcd you only need to #include<LCD.h>.

I have never used FastIO.h which is causing the compile error. There may be a bug in the library which could be reported or followed up in another thread. See if you can get your lcd working with the limited use of #include. Once you get that far, you can decide what to do.

So tried it out and i can see same error as i posted before :-/
Same answer for bperrybap. I added those parts into the files and same error shows up.

Get rid of whatever library you downloaded for your display and just download the library I gave in reply# 5.

HazardsMind:
Get rid of whatever library you downloaded for your display and just download the library I gave in reply# 5.

Thanks. Seems like we you moved me somewhere.
Unfortunatelly, i am still getting this error:

Arduino: 1.5.7 (Windows 8), Board: "Arduino Due (Programming Port)"
sketch_aug07a.ino:20:53: error: 'POSITIVE' was not declared in this scope

I know i changed this line of code from something to this. But i can't remember why, what was there before or where did i get this idea from. Sorry, but i did read a lot of forums and advices trying to find out what is wrong.

Note that last error indicates that you now are using more than one library or have
a sketch that is trying to use fm's library and you don't have fm's library installed.

My advice is to use fm's library as that library is the only library that works on ALL the PCF8574
based backpacks. The other libraries only work on certain vendors backpacks and there is
no guarantee that it works on the backpack that you have.

RadoM:

cattledog:
Just use

#include <Wire.h>

#include <LiquidCrystal_I2C.h>




You do not need the full library for your sketch. If you were using a parallel lcd you only need to #include<LCD.h>.

I have never used FastIO.h which is causing the compile error. There may be a bug in the library which could be reported or followed up in another thread. See if you can get your lcd working with the limited use of #include. Once you get that far, you can decide what to do.

So tried it out and i can see same error as i posted before :-/
Same answer for bperrybap. I added those parts into the files and same error shows up.

It is as I said before all modules have to compile.
The advice that cattledog is offering is wrong.
For a parallel 4 bit interface you include LiquidCrystal.h you do not include LCD.h
fm's library is designed to be backward compatible with the existing LiquidCrystal library so you include the same
header as that library: LiquidCrystal.h
The header LCD.h is an internal header and should not be included by user sketches.

In terms of you getting the same errors, that shouldn't be happening.
Either the edits were not done correctly or there are multiple copies of the library and you have edited
a copy of the files that are not the files actually being used.
Or you have not properly followed the install instructions for the library.
Make sure you fully follow the install instructions, which includes
not having any other libraries that contain the file LiquidCrystal_I2C header file.

At this point you will need to post EVERYTHING you are using/doing/ and the full error message trail.

  1. Use the included example sketch HelloWorld_i2c rather than your own.
    That way we know what you are trying to compile.

  2. zip up your full library directory that you are using so we can see the exact library files
    you are using and see how you have edited them.
    Zip it from the top level so we can see the actual name of directory you used for the library
    when you installed it.
    Attach that zip image in your response.

  3. Turn on verbose output
    [File]->[Preferences]
    check the [] compilation box

Build the sketch, then attach the full message log. Not just part of it but ALL of it
so we can see all the messages and more importantly see which library files are being
used.
Attach that output in your response.


We need to see all of this to see what is going wrong.

--- bill