Quick Setup Guide to Arduino LCD 2004 With PCF8574
by paddyding in Circuits > Arduino
33113 Views, 121 Favorites, 0 Comments
Quick Setup Guide to Arduino LCD 2004 With PCF8574
This is a quick setup guide for your Arduino LCD.
Things you must know before getting started:
1. LCDs are not created equally, some have different pins than the other.
2. Main elements of setting up: the LCD, the library and the code.
Read Your Connectors - Compare to Mine
There are many types of LCDs you can purchase from the internet. I bought mine on ebay and it comes soldered with a PCF8574 backpack.
From my research, by default, I found that the "backpack" connects
-GND to GND
-VCC to 5V or VCC
-SDA to A4
-SCL to A5
Some "backpacks" are different from one another, you can read about this from https://arduino-info.wikispaces.com/LCD-Blue-I2C#v...
Control Your Contrast
Turn the knob on the blue potentiometer using a screwdriver. All the way clockwise increases the pixel whiteness, and darkness vice versa.
Library
If your LCD does not come with a "backpack", you may use the LiquidCrystal library by default from Arduino. (That means you have the one that needs tons of wiring).
Otherwise, LCDs with "backpack" are often related to LiquidCrystal_I2C. Know the difference.
Arduino does not have LCD I2C library by default. The only way is to download it. I spent about an hour looking for the library and essentially I learned about a few things:
1. If your Arduino software is updated to the latest version, download the latest LCD I2C library
2. If you lookup on Google, you will always come across this Liquid Crystal Library by fmalpartida.
3. Apparently that didn't really worked for mine, so I used New_LiquidCrystal_Library.zip instead:
4. Download the library to your Arduino folder, typically located in your Program Files x86.
5. Unzipping the folder is unnecessary.
Adding/ Import Your Library
A library in Arduino is somewhat like a pre-cooked meal. Getting the right library is essential for starting up your LCD.
1. Open your Arduino software click on Sketch>Include Library>Add .zip library.
2. Navigate where you last downloaded your NewLiquidCrystal library and open.
3. Now you can check if the library is installed by going to the Examples and check it out.
The Worst Part: Coding
I spent countless hours finding the right code to power up my LCD but I learned a few tricks that can troubleshoot the problems. Take notes:
1. Make sure your LCD matrix: 16X2 or 20X4? 16 characters with 2 lines or 20 characters with 4 lines?
2. The LCD address, common ones are: 0x3F. 0x27, 0x20, 0x38... these are related to the "backpack" of your LCD.
3. To find your LCD Address... connect your LCD and Arduino, fire up the I2C_scanner code.
Make sure to open your serial monitor and set to Baud 9600 to read the LCD address.
Final Coding
Refer to images: I came to a conclusion that there are 3 things that bothered my process:
1. The LCD address
2. The LCD matrix: some used the code: lcd.init or lcd.begin(20,4) and I think they both work for different libraries.
3. The backlight code is annoying. Sorry but you have to study the code for backlight, essentially you have to read through the code indicating that the backlight is on. (I attached the example codes in Conclusion)
In my case, I use this code because it works: https://bitbucket.org/celem/sainsmart-i2c-lcd/src/...
void setup()
{ lcd.begin (20,4);
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
UPDATE (02/03/2016):
~~lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);~~
I found that removing the backlight code will disable the backlight (obviously), and you will see dimmed texts.
Conclusion
And, you are done.
Reference:
https://arduino-info.wikispaces.com/LCD-Blue-I2C
Library that worked for me +sample codes:
https://brainy-bits.com/tutorials/connect-a-charac...
Commonly used library
https://bitbucket.org/fmalpartida/new-liquidcrysta...
Codes to find your LCD address
http://playground.arduino.cc/Main/I2cScanner
Codes that worked for me + sample codes:
https://bitbucket.org/celem/sainsmart-i2c-lcd/src/...
Extras
Updated 10/09/2016:
I just 3D printed a case for my LCD. I messed up the dimensions, you'll see it in the picture. Download the .STL file and you'll know. The top is slightly modified to enclose the LCD further.