i've bought on ebay an i2c adapter for arduino and a 1602 lcd display(hd44780).i've soldered them and i can't get it controlled by an arduino mini pro.
my question before i "try to fix" anything: Is it normal if i power up the display trough the i2c board to display a full row of pixels,the lower one empty,and backlight on?
if i connect the vcc and gnd,the backlight starts,and the lcd shows the upper row of pixels all white and lower one empty.i've tryed to change pins from arduino connecting sda and scl,modify the program but nothing is displayed.
...but before i do anything,could anyone tell me if it's ok the display.i can upload pictures if someone asks.thanks!
the upper row of an 16x2 lcd is always filled with bars when it is correctly (electrical) wired.
try running the follwoing script
(change he adress of the display to your settings: LiquidCrystal_I2C lcd(0x20....<-- this is the lcd adress
/* 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 0x27 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(0x20, 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(16,2); // 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 ) */
The sketch is for a 4x20, but has to run also on your display (but of course displays not all charcters 8) )
But so you can test if it works....
Best is (if not) you post a pic of your wiring and the code you are using !
My preference is not to use a "just guess" or "trial and error" or "Hey, just try this" methodology when
trying to get something working. To me it just wastes time and has the potential to damage something.
So before running off and guessing at things, it would be better if you post a photo
of the backpack you have and how it is soldered to the display.
That way we can make sure it is soldered properly
and should be able to give you the
needed information to get the proper library configured to make it work.
Until we see which backpack you have, there is no way for anybody to give you the
information to make it work, as there are several different i2c backpacks and they
work slightly differently.
Is it normal if i power up the display trough the i2c board to display a full row of pixels,the lower one empty,and backlight on?
You will get that display when the power and contrast are correct. It means that the device has gone through it's internal initialization routine and has configured itself in the default configuration (which is almost never the desired configuration). This means that your program has not successfully initialized the program due to some problem with the wiring or the programming or both.
floresta:
You will get the row of blocks with only pins 1, 2, and 3 correctly wired.
Isn't it also possible to get the blocks when the i2c backpack is soldered on to the LCD backwards/upsidedown?
The power pins (1 & 2) will be getting power from the backlight power pins (15 & 16)
and then LCD pin 3 will be hooked up to the connection that should be connected
to pin 14 which is the D7 pin.
If the PCF8574 is setting the output pin that should be connected to D7 to low
that low would ground LCD pin 3 and then wouldn't the LCD blocks on the display light up?
In fm's library, the LCD class handles all the common hd44780 initialization and API.
The last thing that the begin() code does is turn on the backlight.
If the backlight is configured, it turns it on by setting the 8574 output pin/bit to turn
on the backlight. All other bits in the 8574 output port will be set to 0 which will
force LCD pin D7 to low.
If the backlight is not configured the begin() code will end by setting
LCD_ENTRYMODESET | LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT
which is 0x04 | 0x02 | 0x00
which also will leave the the D7 pin low.
So I'm thinking that a backwards soldered backpack could also create the reported conditions.
Isn't it also possible to get the blocks when the i2c backpack is soldered on to the LCD backwards/upsidedown?
The power pins (1 & 2) will be getting power from the backlight power pins (15 & 16)
and then LCD pin 3 will be hooked up to the connection that should be connected
to pin 14 which is the D7 pin.
If the PCF8574 is setting the output pin that should be connected to D7 to low
that low would ground LCD pin 3 and then wouldn't the LCD blocks on the display light up?
That sounds quite possible since it has happened with some of the non-standard parallel pinout devices in the past.
Even for a lcd with a standard pinout, I've also seen at least one instance of the backpack being soldered upside down to the LCD.
Some i2c backpacks need to be soldered with the components facing down (twards the LCD PCB) vs up so you
have to look closely for the pin 1 designator on the backpack.
i've double checkd before soldering the i2c to lcd.the i2c has marked the first pin with a white square.the lcd has numbers on each pin.i've attached pictures with front display,back and just powered on (vcc+gnd).i will try later to upload the code to see what is happening.thanks for fast replay to all'ya
as for electronics,i have a few years of experience .but never is enough and i want to learn a few new things,and maybe,if i will understand it better,i will teach my little brother the amazing world of microcontrolers
and sorry for the poor quality of the pictures,they were made with a mobile phone
maybe i'm not connecting the i2c to arduino right....i use pin 4 and 5 as i've read on a few sites.do i have to configure pins or something?or use other pins?
I'm likely to encounter similar difficulties soon as I'm waiting for a similar I2C adaptor and my first UNO to arrive.
I've used a 16x02 LCD display with HD44780 before but only with parallel connection on a breadboard but not with Arduino.
Is the adaptor happy with 5V from the Arduino?
Is the address correct?
i supply 5 volts from usb,trough FTDI addaptor.it has spare VCC and GND pins,and i use them for powering up matrix or lcd.
it seems ok,and should be ok as long as power consumption does not exceed 600-700mA.usb port supports by standard 500mA,but sometimes you can get 600-700mA,even 1000mA,depending on the motherboard.
OK, what you have not explained is what Arduino you are using. The I2C interface is not just pin 4 and 5, but whichever pins are denoted for that board - as SDA and SCL. For a UNO, (Pro) Mini or a Nano it is A4 and A5, not digital 4 and 5, for a Leonardo it is digital 2 and 3.
If the sketch you have then does not work, run the I2Cguesser sketch to find the correct descriptor.
A single LCD module should run OK from the Arduino 5V.
wooohooooo at last it's working....not well but it's working...
so thank you verry much for pointing me out that it's not using pin 4 and 5 but pin A4 and A5
now...if i use the address 0x20 it's not showing anything.if i use the address 0x27 it shows on the display...and as the program say,the address it's supposed to be for a 4 rows 20 characters display....strange,but i can handle that
A.R.Ty:
No, the adress is set by the three jumpers/solder points A0 A1 A2 on the I2C backpack
Not entirely true.
While some of the address is set by the jumpers, (the lower 3 bits) the upper
bits are determined by the chip.
sebulica,
Did the guesser sketch work?
What constructor are you using?
What is the name of the backpack that you have? (is there any lettering on the board?)
use backlight() and noBacklight() to turn the backlight on/off.