最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Arduino LCD 液晶顯示器教程

2023-03-06 15:51 作者:宇宙很大腦洞很圓  | 我要投稿

什么是LCD1602液晶顯示器??

LCD的全稱是Liquid Crystal Display,液晶顯示器。它的特點(diǎn)是利用點(diǎn)陣來(lái)顯示字符, 比如英文字母、阿拉伯?dāng)?shù)字、簡(jiǎn)單的漢字和一般性符號(hào)。因?yàn)槊總€(gè)字節(jié)的點(diǎn)陣數(shù)太少, 所以復(fù)雜的漢字很難顯示清晰。

LCD1602每行有16個(gè)字格,共有2行。每個(gè)字格有40個(gè)像素, 可組成5列*8行的LCD矩陣。每個(gè)像素可用二進(jìn)制表示, 1為亮燈, 0為滅燈。詳情見(jiàn)圖一。

圖一:LCD1602 字節(jié)顯示方法

LCD1602總共有16個(gè)引腳。每個(gè)引腳的作用如下。

圖二:引腳詳情

如何連接電路

材料清單:

Arduino Uno 開(kāi)發(fā)板 x1

USB接線 x1

面包板 x1

LCD液晶顯示器1602 x1

電位器 x1 (可用電阻器替代)

雙公頭面包線若干(長(zhǎng)黃線x4, 長(zhǎng)橘線x1, 長(zhǎng)藍(lán)線x1, 短綠線x1, 短黑線x5, 短紅線x4)

裝有Arduino IDE程序的電腦 x1

面包線的顏色僅供參考,方便于理解下面的教程。黑線一般作為接地線,紅線作為電源線。

電路圖:?

圖三:用電位器作為電阻?

圖四:用電阻器作為電阻 (其他部分跟圖三差不多)
圖五:接線細(xì)節(jié)

接線步驟:

步驟一:把LCD連到面包板上
步驟二:加上電阻,調(diào)節(jié)顯示屏對(duì)比度

步驟三: 把面包板上所有的紅線接正極/電源(面包板第二行),黑線接負(fù)極/地(面包板第一行)。

步驟四:把面包板接到開(kāi)發(fā)板上。加一條紅線連接正極到開(kāi)發(fā)板上的5V, 加一條黑線連接負(fù)極到開(kāi)發(fā)板上的GND。

步驟五:把面包板上的黃線從D4接到引腳4, D5到5, D6到6, D7到7。把橘線從RS接到引腳1, 藍(lán)線從E到引腳2。

步驟六:把開(kāi)發(fā)板用usb連接到電腦。

步驟七: 根據(jù)視頻內(nèi)容上傳代碼。【Arduino LCD 液晶顯示器教程】?

代碼

#include <LiquidCrystal.h> ? ? ? ? ? ? // includes the LiquidCrystal Library

LiquidCrystal lcd(1, 2, 4, 5, 6, 7); ?// Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)

/**

? Create customised characters / symbols

? 自創(chuàng)字符

*/

byte heart[8] = { ? // Each character comprises of 40 pixels (8 rows and 5 columns)

? B00000, ? ? ? ? ?// B stands for binary formatter and the five numbers are the pixels

? B01010, ? ? ? ? // Use 1 to light up the pixel, 0 does nothing

? B11111,

? B11111,

? B01110,

? B00100,

? B00000,

? B00000

};

byte smile[8] = {

? B00000,

? B00000,

? B01010,

? B00000,

? B10001,

? B01110,

? B00000,

? B00000

};

/**

? Initial setup

? 初始設(shè)置

*/

void setup() {

? lcd.begin(16,2); // Initialise the interface to the LCD screen, and specifies the dimensions (width and height) of the display ?

? lcd.createChar(0, heart); ?// Create a custom character heart

? lcd.createChar(1, smile); ?// Create a custom character smile

}

/**

? Loop

? 循環(huán)

*/

void loop() {

? lcd.setCursor(0,0); ? // Move cursor to 1st column, 1st row

? lcd.print("Hello!"); // Print on the LCD


? lcd.setCursor(7,0); ? // Move cursor to 8th column, 1st row

? lcd.write(byte(0)); ?// Display custom character 0, the heart


? lcd.setCursor(2,1); ? ? ? ? // Move cursor to 3rd column, 2nd row

? lcd.print("LCD Tutorial"); ?// Print on the LCD


? lcd.setCursor(15,1); ? // Move cursor to 16th column, 2nd row

? lcd.write(byte(1)); ? // Display custom character 1, the smile

? delay(5000); ? ? ? ? //Wait for 5 seconds


? lcd.clear(); ? ? ? ?// Clear the display


? lcd.setCursor(0,0); ?// Move cursor to 1st column, 1st row

? lcd.blink(); ? ? ? ?//Display the blinking LCD cursor

? delay(3000); ? ? ? //Display for 5 seconds


? lcd.setCursor(0,0); ? // Move cursor to 1st column, 1st row

? lcd.noBlink(); ? ? ? // Turn off the blinking LCD cursor

? lcd.cursor(); ? ? ? // Display an underscore at on the specified cell (0,0)

? delay(3000); ? ? ? // Wait for 5 seconds ?


? lcd.noCursor(); ?// Hide the LCD cursor

? delay(3000); ? ?// Wait for 5 seconds ?


? lcd.clear(); ?// Clear the display

?

? /** Scroll text to the left **/

? for (int i = 16; i >= 1; i--) {

? ? lcd.setCursor(i, 0);

? ? lcd.print("LCD");

? ? lcd.setCursor(i, 1);

? ? lcd.print("Tutorial");

? ? delay(1000);

? ? lcd.clear();

? }

? delay(1000);

}




Arduino LCD 液晶顯示器教程的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
泽普县| 乾安县| 河源市| 皋兰县| 蒲江县| 临西县| 玛曲县| 十堰市| 北宁市| 万源市| 商洛市| 杭州市| 德阳市| 金门县| 青州市| 东宁县| 嘉义县| 漳浦县| 溧阳市| 威远县| 玛纳斯县| 富阳市| 河津市| 尼木县| 益阳市| 西丰县| 定日县| 武城县| 车致| 西贡区| 信宜市| 天镇县| 桃江县| 永登县| 陇南市| 沂源县| 嘉禾县| 米泉市| 图们市| 嘉兴市| 息烽县|