Go Down

Topic: prgraming a 20 x 4 lcd (Read 458 times) previous topic - next topic

brenden_nerd_

ok so i recently bought a 20 x 4 lcd with i2c and i was wondering where in the code i put the i2c id at?
i am using a library from here https://github.com/andatche/arduino-lcd03
this is the code i have for my display 0x3F
this is the code :
/*
  HelloWorld.ino - Arduino library for I2C LCD03 display from Robot Electronics
  see http://www.robot-electronics.co.uk/htm/Lcd03tech.htm
  Copyright (c) 2013 Ben Arblaster.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
#include <Wire.h>
#include <LCD03.h>
 
// Create new LCD03 instance
LCD03 lcd;
 
void setup() {
  // Initialise a 20x4 LCD
  lcd.begin(20, 4);
 
  // Turn on the backlight
  lcd.backlight();
 
  // Write to the LCD
  lcd.print("Hello world");
 
  // Wait for 5 seconds
  delay(5000);
 
  // Clear the LCD
  lcd.clear();
}
 
void loop() {
  // Set the cursor to the top left
  lcd.home();
 
  // Print the uptime in millis
  lcd.print(millis());
}

jurs

ok so i recently bought a 20 x 4 lcd with i2c and i was wondering where in the code i put the i2c id at?
As you can read in the source code you posted:
> Arduino library for I2C LCD03 display from Robot Electronics

The library code seems to be made for one special LCD of one special manufacturer.

So most likely the address is hard-coded in the library.
And the library will know about the address when using a "LCD03 display from Robot Electronics"


So most likely the library needs a rewrite, if you want to use a different model of LCD.

aarg

It's documented at the github site you posted.
Quote
LCD03(i2c_address)

New LCD03 at i2c_address.

i2c_address (char): 8-bit I2C address of the display (as displayed during initilisation)
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

gpop1

There are lots of different library's available especially for i2c 20 x 4 displays. Sometimes the first library you find is not the one that suits you best.

No matter which library you use a useful tool is

 // I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

as some displays sold are not addressed to what the vendor claims.

aarg

as some displays sold are not addressed to what the vendor claims.
Yes, and some I2C backpack PCB's have the same address, but a different pinout to the LCD.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

OldSteve

#5
Dec 26, 2015, 04:10 am Last Edit: Dec 26, 2015, 04:11 am by OldSteve
@brenden_nerd_ , you say the I2C address for your LCD module is 0x3F, yet the LCD03 display from Robot Electronics appears to use the address 0xC6, so can we assume that you definitely have a different I2C LCD module?

If so, you're probably better off using the "New LiquidCrystal" library.
New LiquidCrystal
It has a "LiquidCrystal_I2C.h" include file that works well with most I2C LCD modules.
*Note that to use this library you need to remove/delete the original "LiquidCrystal" library to avoid conflicts.

Are you using an LCD with separate I2C backpack, or an integrated module?
A photo would help, or a link to it online.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

Go Up