In previous post, I showed about the character LCD interfacing with Arduino Uno. It use a parallel data transmission method between the LCD and the Arduino module. We can add a serial to parallel converter IC to make an ease of connection between those two modules. The PCF8574T is an I2C to 8-bit parallel I/O converter chip, comes with small size. It's suitable for character LCD controlling. I2C uses only two wire, SDA, and SCL.
PCF8574T character LCD interface module |
There are many LCD controlling module based on the PCF8574T on online stores. It's ready to use, since they are designed for character LCD. Some of them are soldered and sold with the character LCD module at low price.
In this example, I use this module connecting with a 16x2 character LCD. It will show a total duration since the Arduino started up.
Running program |
I use two libraries in this example,
The Wire.h comes with the IDE. But the other two's we need to install. Two I2C pins stay with the same pin of the Arduino analog inputs,
- SDA - A4
- SCL - A5
The default I2C address of PCF8574T 0x27, whenever its three address pins are opened.
Address pin for PCF8574T module |
However it's not necessary to change its address here.
#include <Wire.h> #include <LiquidCrystal_I2C.h> #include <TimerOne.h> //Default address 0x27, LCD is 16x2 LiquidCrystal_I2C lcd(0x27,16,2); void setup(){ //Initialize the LCD lcd.init(); //Turn On Backlight lcd.backlight(); lcd.print("PCF8574T I2C LCD"); lcd.setCursor(0,1); lcd.print("Arduino Example"); delay(3000); lcd.clear(); lcd.home(); lcd.print("Powered Up Time:"); //Timer1 duration is 1 second Timer1.initialize(1000000); Timer1.attachInterrupt(secondCounts); } int days,hours,minutes,seconds; void loop(){ lcd.setCursor(0,1); //Show the days, hour, minute, and second lcd.print(String(days)+" "+String(hours)+":"+String(minutes)+":"+String(seconds)+" "); } void secondCounts(){ seconds++; //Finding the minutes if(seconds>=60){ minutes++; seconds=0; } //Finding the hours if(minutes>=60){ hours++; minutes=0; } //Finding the days if(hours>=24){ days++; hours=0; } }
It schematic diagram is very simple.
Wiring diagram |
Click here to download its source file.
No comments:
Post a Comment