天天看點

傑x分享(28):Arduino(十七)

作者:LearningYard學苑
傑x分享(28):Arduino(十七)

分享興趣,傳播快樂,

增長見聞,留下美好。

親愛的您,這裡是LearingYard學苑!

今天小編為您帶來"Arduino的學習"

歡迎您的通路!

Share interest, spread happiness,

increase knowledge, and leave beautiful.

Dear, this is the LearingYard Academy!

Today, the editor will bring you"Learning Arduino"

Welcome to visit!

思維導圖Mind mapping

傑x分享(28):Arduino(十七)

要使用Arduino控制LCD1602液晶顯示屏,你需要按照以下步驟操作:

To control the LCD1602 liquid crystal display with Arduino, you need to follow the steps below:

1. 連接配接硬體:首先,将LCD1602子產品連接配接到Arduino闆上。根據你選擇的連接配接方式(4線或8線),接線會有所不同。下面是4線模式的接線示例:LCD1602的VSS引腳連接配接到Arduino的GND。LCD1602的VDD引腳連接配接到Arduino的5V。LCD1602的V0引腳通過一個10kΩ的電位器連接配接到Arduino的5V和GND之間,用于調節對比度。LCD1602的RS引腳連接配接到Arduino的數字引腳7。LCD1602的RW引腳連接配接到Arduino的GND(因為通常我們隻寫入資料)。LCD1602的E引腳連接配接到Arduino的數字引腳8。LCD1602的D4引腳連接配接到Arduino的數字引腳9。LCD1602的D5引腳連接配接到Arduino的數字引腳10。LCD1602的D6引腳連接配接到Arduino的數字引腳11。LCD1602的D7引腳連接配接到Arduino的數字引腳12。LCD1602的A引腳(背光正極)連接配接到Arduino的5V。LCD1602的K引腳(背光負極)連接配接到Arduino的GND。

1. Connect hardware: First, connect the LCD1602 module to the Arduino board. According to the connection method (4 or 8 lines) you choose, the wiring will be different. Below is a wiring example of the 4 -line mode: The VSS pin of the LCD1602 is connected to the GND of Arduino. The VDD pin of LCD1602 is connected to Arduino's 5V. The V0 pin of the LCD1602 is connected to the 5V and GND of Arduino through a 10kΩ potentiometer to regulate the contrast. The RS pin of the LCD1602 is connected to the number pin 7 of Arduino. The RW pin of the LCD1602 is connected to the GND of Arduino (because we usually only write data). The E pins of LCD1602 are connected to the number pin 8 of Arduino. The D4 pin of the LCD1602 is connected to the number pin 9 of Arduino. The D5 pin of the LCD1602 is connected to the number pin 10 of Arduino. The D6 pin of the LCD1602 is connected to the number pin 11 of Arduino. The D7 pin of the LCD1602 is connected to the number pin 12 of Arduino. LCD1602's A pin (backlight positive) is connected to 5V of Arduino. The K pins (backlight negative) of LCD1602 are connected to the GND of Arduino.

2. 安裝庫:確定你已經安裝了LiquidCrystal庫。如果沒有,可以在Arduino IDE中通過“管理庫”功能安裝。

2. Installation library: Make sure you have installed the liquidCrystal library. If not, you can install it through the "Management Library" function in Arduino IDE.

3. 編寫代碼:使用LiquidCrystal庫來控制LCD1602。以下是一個簡單的示例代碼,用于在LCD1602上顯示“Hello, World!”:

3. Write code: Use the liquidCrystal library to control LCD1602. The following is a simple example code, which is used to display "Hello, World!" On LCD1602:

```cpp

#include

// 初始化LCD對象,指定引腳

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {

// 設定LCD的列數和行數

lcd.begin(16, 2);

// 列印問候語

lcd.print("Hello, World!");

}

void loop() {

// 這裡可以添加其他需要循環執行的代碼

}

```

4. 上傳代碼:将Arduino闆通過USB線連接配接到電腦,打開Arduino IDE,選擇正确的闆型和端口,然後上傳代碼到Arduino。

4. Upload code: Connect the Arduino board through the USB cable to the computer, open the Arduino IDE, select the correct board and port, and then upload the code to Arduino.

5. 測試和調整:上傳代碼後,LCD1602應該會顯示“Hello, World!”。如果顯示不清晰,可以通過調整連接配接到V0引腳的電位器來改變對比度。

5. Test and adjustment: After uploading the code, LCD1602 should display "Hello, World!". If the display is not clear, the contrast can be changed by adjusting the potentiometer connected to the V0 pin.

通過這個基礎示例,你可以根據自己的需求修改代碼,以顯示不同的文本或資料。例如,你可以讀取傳感器資料并在LCD上顯示,或者建立一個使用者界面來與使用者互動。

Through this basic example, you can modify the code according to your needs to display different texts or data. For example, you can read sensor data and display on LCD, or create a user interface to interact with users.

今天的分享就到這裡了。

如果您對今天的文章有獨特的想法,

讓我們相約明天。

祝您今天過得開心快樂!

That's all for today's sharing.

If you have a unique idea about the article,

please leave us a message,

and let us meet tomorrow.

I wish you a nice day!

參考資料:谷歌翻譯、百度、B站

本文由LearningYard新學苑整理并發出,如有侵權請背景留言溝通