Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
👉 Ready to explore and create with us? Click [here] and join today!
1.1.6 I2C LCD1602
Introduction
LCD1602 is a character type liquid crystal display, which can display 32 (16*2) characters at the same time.
Components
Schematic Diagram
T-Board Name |
physical |
SDA1 |
Pin 3 |
SCL1 |
Pin 5 |
Experimental Procedures
Step 1: Build the circuit.
Step 2: Setup I2C (see I²C Configuration. If you have set I2C, skip this step.)
Step 3: Go to the folder of the code.
cd ~/davinci-kit-for-raspberry-pi/nodejs/
Step 4: Install dependencies.
sudo npm install @oawu/lcd1602
Step 5: Run the code.
sudo node i2c_lcd1602.js
After the code runs, you can see Greetings!!, From SunFounder displaying on the LCD.
Code
const LCD = require('@oawu/lcd1602');
const lcd = new LCD();
lcd.text(0, 0, 'Greetings!!');
lcd.text(1, 1, 'from SunFounder');
Code Explanation
const LCD = require('@oawu/lcd1602');
const lcd = new LCD();
Import the lcd1602 module and represent it with lcd.
Note
For the lcd1602 module, please refer to: https://www.npmjs.com/package/@oawu/lcd1602
lcd.text(0, 0, 'Greetings!!');
lcd.text(1, 1, 'from SunFounder');
Calling the encapsulated text() function in the LCD class can make the lcd1602 display the text we want.
The text() function receives three parameters,
the first parameter is the line of lcd1602,
the second parameter represents the position of the displayed text,
and the third parameter represents the text we want to display.
The 1602 number in the LCD model means it has 2 rows of 16 cells each.
Phenomenon Picture