# LCD1602液晶模組

![](/files/-Lx07QqqpiXAOp8KNI5q)

## 專案說明

使用「科易KEYES Arduino UNO R3 開發板」連接「LCD1602液晶模組」, 在LCD1602液晶模組上顯示「Hello World」。

此**LCD1602液晶模組**包含於「[洞洞兩教學材料包 Education Kit 002](https://www.robotkingdom.com.tw/product/rk-education-kit-002/)」內。

## KEYES Arduino UNO R3電路圖

* [KEYES Arduino UNO R3&#x20;  ](https://www.robotkingdom.com.tw/product/keyes-uno-r3/)
* 通用型彩色Sensor shield v5.0感測器擴充板
* LCD1602液晶模組

**LCD1602液晶模組**是**I2C訊號**輸出， 可以接「I2C」的KEYES Arduino UNO R3訊號端上。本範例連接到「I2C」，「**SDA**」**←→**「**SDA**」，「**SCL**」**←→**「**SCL**」

{% hint style="info" %}
I2C 液晶顯示模組有PCF8574及PCF8574A這二種晶片，而其中PCF8574晶片初始化I2C位址為0x27；PCF8574A晶片初始化I2C位址為0x3F

如發現液晶顯示模組有沒有正常顯示畫面，另一個可能即是對比預設調整太低，轉動模組背後的可變電阻(如下圖紅框處)把對比值調整至可看清楚之閥值即可顯示畫面。
{% endhint %}

![](/files/-Lx07y89jJntq6X_mbea)

![](/files/-M0q5kBR2Vj-4kpfTBmB)

## Arduino 程式

由於LCD1602液晶模組是函式庫型模組，所以需要先在Arduino上下載函式庫，下載方法如下。

在Arduino上選擇工具，選擇管理程式庫，在管理程式庫搜尋LiquidCrystal I2C選擇LiquidCrystal I2C by Frank de Brabander版本1.1.2並安裝。

![](/files/-Lx083tCgabInrUNTcBj)

![](/files/-Lx086S_mQo18zGf2gem)

在I2C 1602液晶顯示模組上第一列顯示「Hello World」第二列顯示「Hello World2」。

產生出的 Arduino 程式如下

```c
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Hello World");
  lcd.setCursor(0,1);
  lcd.print("Hello World2");
}


void loop()
{
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cavedu.gitbook.io/cavedu/rk002/module/002_lcd1602.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
