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 #223 background imageLoading...
Page #223 background image
223
Chapter 20 LCD1602
www.freenove.com
support@freenove.com
Code
This code will get the CPU temperature and system time of RPi, display them on LCD1602.
C Code 20.1.1 I2CLCD1602
First observe the project result, and then analyze the code.
1. Use cd command to enter 20.1.1_ I2CLCD1602 directory of C code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/20.1.1_I2CLCD1602
2. Open the file I2CLCD1602.c, and find the macro definition "pcf8574_address". If your serial-to-parallel
module uses chip PCF8574, set the macro "pcf8574_address" value to 0x27.If your serial-to-parallel
module uses chip PCF8574A, set the macro "pcf8574_address" value to 0x3F.
3. Use following command to compile “I2CLCD1602.cand generate executable file “I2CLCD1602”.
gcc I2CLCD1602.c -o I2CLCD1602 -lwiringPi -lwiringPiDev
4. Then run the generated file I2CLCD1602”.
sudo ./ I2CLCD1602
After the program is executed, LCD1602 screen will display current CPU temperature and system time.
If there is no display or the display is not clear, rotate white knob in back of LCD to adjust the contrast
of LCD1602 until the screen can display clearly.
The following is the program code:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdlib.h>
#include <stdio.h>
#include <wiringPi.h>
#include <pcf8574.h>
#include <lcd.h>
#include <time.h>
//#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

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