2016年1月16日 星期六

Arduino UNO學習260.內建範例-外接顯示器



Arduino學習260.內建範例-外接顯示器

LCD顯示器有很多種,接腳有14和16針2種,差異於背光
由於Arduino腳位有限,一般使用4位元方式傳送
1602模組腳位說明
1=Vss=接地0V
2=Vdd=電源+5V
3=Vo=對比0~+5V,接可變電阻調整對比
4=RS=資料暫存器
5=RW=讀取或寫入
6=E=Enabl致能信號
7=D0=Data I/O
8=D1=Data I/O
9=D2=Data I/O
10=D3=Data I/O
11=D4=Data I/O
12=D5=Data I/O
13=D6=Data I/O
14=D7=Data I/O
15=A+=背光電源(可不接)
16=K-=背光接地(可不接)

硬體
LCD液晶顯示器模組*1
可變電阻(電位器)*1
此外接螢幕需安裝資料庫

打開內建範例,,檔案>範例>LiquidCrystal>Hello World
// 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);

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() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}


上傳後慢慢調整電位器可變電阻,直到液晶螢幕出現字樣
由於接線較多,經常會有接觸不良顯示不出的情形,故市售另有1602轉接模組,將電阻及接線等簡化為4線,使用更簡單


沒有留言:

張貼留言