當前位置:編程學習大全網 - 編程軟體 - arduino怎麽接lcd顯示屏

arduino怎麽接lcd顯示屏

LCD顯示屏模塊

LCD顯示屏與Arduino連接可以有兩種方式:

直接與Arduino相連

通過轉接板利用I2C的方式與Arduino相連

1. 直接與Arduino相連

直接與Arduino相連的好處是不用現另外購買轉接板,但這樣造成的後果就是要大量占用Arduino的IO口。如果妳的項目外接的傳感器不多,那還好,但如果妳需要外接很多個傳感器或者其他配件,那妳的IO口就會告急了~

所需材料

1x Arduino UNO

1x LCD 16x2

1x 10KΩ旋轉變阻器

1x 面包板

接線示意圖

LCD直接與Arduino相連的接線圖

LCD Arduino

RS -> 12

E -> 11

D4 -> 5

D5 -> 4

D6 -> 3

D7 -> 2

VCC -> 5V

R/W -> GND

GND -> GND

LCD 旋轉變阻器

VCC -> 左邊引腳

Vo -> 中間引腳

R/W -> 右邊引腳

GND -> 右邊引腳

加載庫文件

在Arduino IDE 1.6.2 或者以上版本中, 項目->加載庫->管理庫中搜索LiquidCrystal,然後安裝即可。

示例代碼

// 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);

}

  • 上一篇:編程構件是可編程的
  • 下一篇:Sock傳輸數據快還是直接連接數據庫傳輸數據快?
  • copyright 2024編程學習大全網