2014年8月18日 星期一

LCD 1602介紹

由於許多電子線路必須將內部的狀態資訊顯示到外界,供使用者讀取資訊,方能夠繼續使用,所以我們必須提供一個可以顯示電子線路內在資訊的顯示介面,所以我們必須要具備一個獨立的顯示螢幕,方能稱為一個完整的設計。
為了達到這個目的,先行介紹Arduino開發板常用LCD 1602 ,常見的LCD 1602是和日立的HD44780[1] 相容的 2x16 LCD 可以顯示兩行資訊,每行 16 個字元,它可以顯示英文字母、希臘字母、標點符號以及數學符號。
除了顯示資訊外,它還有其它功能,包括資訊捲動(往左和往右捲動)、顯示游標和 LED背光的功能,但是有一些廠商為了降低售價,取消其LED背光的功能。
26所示,大部分的LCD 1602都配備有背光裝置,所以大部份具有16個腳位,可以參考 3,可以更深入了解其接腳功能與定義:
26 LCD1602 接腳

3 LCD1602 接腳說明表
接腳
接腳說明
接腳名稱
1
Ground (0V)
接地 (0V)
2
Supply voltage; 5V (4.7V – 5.3V)
電源 (+5V)
3
Contrast adjustment; through a variable resistor
螢幕對比(0-5V), 可接一顆 1k 電阻,或利可變電阻調整適當的對比
4
Selects command register when low; and data register when high
Register Select:
  1: D0 D7 當作資料解釋
  0: D0 D7 當作指令解釋
5
Low to write to the register; High to read from the register
Read/Write mode:
  1: LCD 讀取資料
  0: 寫資料到 LCD

因為很少從 LCD 這端讀取資料,可將此腳位接地以節省 I/O 腳位。
6
Sends data to data pins when a high to low pulse is given
Enable
7
8-bit data pins
Bit 0 LSB
8
Bit 1
9
Bit 2
10
Bit 3
11
Bit 4
12
Bit 5
13
Bit 6
14
Bit 7 MSB
15
Backlight VCC (5V)
背光(串接 330 R 電阻到電源)
16
Backlight Ground (0V)
背光(GND)
為了讓實驗更順暢進行,先行介紹LCD1602 (Guangzhou_Tinsharp_Industrial_Corp._Ltd., 2013) ,我們參考 27所示,如何將LCD 1602Arduino開發板連接起來,並可以參考 28之接線圖,將LCD 1602Arduino開發板進行實體線路連接,參考附錄中,LCD 1602 函式庫 單元,可以見到LCD 1602常用的函式庫(LiquidCrystal Library,參考網址:http://arduino.cc/en/Reference/LiquidCrystal ),若讀者希望對LCD 1602有更深入的了解,可以參考附錄中LCD 1602原廠資料(Guangzhou_Tinsharp_Industrial_Corp._Ltd., 2013),相信會有更詳細的資料介紹
LCD 1602 4-bit 8-bit 兩種使用模式,使用 4-bit 模式主要的好處是節省 I/O 腳位,通訊的時候只會用到 4 個高位元 (D4-D7)D0-D3 這四支腳位可以不用接。每個送到 LCD 1602的資料會被分成兩次傳送先送 4 個高位元資料,然後才送 4 個低位元資料。


27 LCD 1602接線示意圖
使用工具 by Fritzing (Interaction_Design_Lab, 2013)


28 LCD 1602接線圖
使用工具 by Fritzing (Interaction_Design_Lab, 2013)

我們參考Arduino官方網站 http://arduino.cc/en/Reference/LiquidCrystal  ,其連接LCD 1602哦範例程式,可以見到Arduino如何驅動LCD 1602
LiquidCrystal LCD 1602測試程式(lcd1602_hello)
/*
LiquidCrystal Library - Hello World

Use a 16x2 LCD display The LiquidCrystal
library works with all LCD displays that are compatible with the 
Hitachi HD44780 driver. 
This sketch prints "Hello World!" to the LCD
and shows the time.
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);   //use db4-db7 as pin 5-2
void setup() {
// set up the LCD's number of columns and rows: 
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print(millis()/1000); }





[1] Hitachi HD44780 LCD controller is one of the most common dot matrix liquid crystal display (LCD) display controllers available. Hitachi developed the microcontroller specifically to drive alphanumeric LCD display with a simple interface that could be connected to a general purpose microcontroller or microprocessor

沒有留言:

張貼留言