11:33 pm
March 20, 2015
I have built my own I2C interface for an LCD using the PCF8574 chip that is used on the Sainsmart LCD.
My PCF8547 is on address 0X20 as can be seen in the Arduino I2C scanner sketch output below
So I changed the example code to fit my circuit as seen below.
But when I run the example all I get is two rows of blocks.
I have checked and checked my circuit, tried different LCD's and another PCF8574 chip but nothign helps.
12:58 am
March 20, 2015
Yes running this test 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 0x3F // <<----- 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("SainSmartI2C16x2");
}
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);
}
It runs fine
3:38 am
March 12, 2015
I think your problem is your I2C address. Looks like you are using decimal 20, not hex 20. You should be using decimal 32 instead.
This post was something similar:
https://www.geverywhere.com/for.....t-working/
Also, it is expected that the LCD would not be cleared after resetting the Arduino if the newly downloaded code did not have the correct I2C address. The LCD module will retain and refresh the LCD with the old data since it would not be receiving any new commands because of the I2C address mismatch.
3:57 am
March 20, 2015
Steffan said
Also, if your test code above worked, that's using I2C address 0x3F, not 0x20. So you would want to use address (decimal) 63 in that case.
I uploaded the wrong sketch not the one where I change the address to 0x20
But you were right I was confusing the number bases and setting the address to 20 decimal instead of 20 hex
I set the display properties to hex and show radix then set it to 20 hex and it works
20
1 Guest(s)