EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #225 background imageLoading...
Page #225 background image
225
Chapter 20 LCD1602
www.freenove.com
support@freenove.com
58
59
60
61
62
63
64
65
66
67
68
69
70
digitalWrite(RW,LOW); // allow writing to LCD
lcdhd = lcdInit( 2,16,4,RS,EN,D4,D5,D6,D7,0,0,0,0);// initialize LCD and return “handle
used to handle LCD
if(lcdhd == -1){
printf("lcdInit failed !");
return 1;
}
w hile(1){
printCPUTemperature();// print CPU temperature
printDataTime(); // print system time
delay(1000);
}
r eturn 0;
}
It can be seen from the code that PCF8591 and PCF8574 have a lot of similarities, they are through the I2C
interface to expand the GPIO RPI. First defines the I2C address of the PCF8574 and the Extension of the GPIO
pin, which is connected to the GPIO pin of the LCD1602.
//#define pcf8574_address 0x27 // default I2C address of Pcf8574
#define pcf8574_address 0x3F // default I2C address of Pcf8574A
#define BASE 64 // BASE is not less than 64
//////// Define the output pins of the PCF8574, which are directly connected to the
LCD1602 pin.
#define RS BASE+0
#define RW BASE+1
#define EN BASE+2
#define LED BASE+3
#define D4 BASE+4
#define D5 BASE+5
#define D6 BASE+6
#define D7 BASE+7
Then, in main function, initialize the PCF8574, set all the pins to output mode, and turn on the LCD1602
backlight.
pcf8574Setup(BASE,pcf8574_address);// initialize PCF8574
for(i=0;i<8;i++){
pinMode(BASE+i,OUTPUT); // set PCF8574 port to output mode
}
digitalWrite(LED,HIGH); // turn on LCD backlight
Then use lcdInit() to initialize LCD1602 and set the RW pin of LCD1602 to 0 (namely, can be write ) according
to requirements of this function. The return value of the function called "Handle" is used to handle LCD1602"
next.
lcdhd = lcdInit(2,16,4,RS,EN,D4,D5,D6,D7,0,0,0,0);// initialize LCD and return
handleused to handle LCD

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish