這來試試 LCD 20x4 lines, 利用Arduino加上 IO Board 接線方便許多!
可顯示的字元比 常用LCD 16x2 lines 多許多!
步驟一: 下載 I2C LCD library, 解壓縮後放入Arduino Libraries內
步驟二: 撰寫程式如下:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// set the LCD address to 0x20 for a 20 chars 4 line display
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
//假設 I2C address 0x27
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600); /
lcd.begin(20,4);
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight();
lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Motoduino Lab!");
lcd.setCursor(2,1);
lcd.print("www.motoduino.com");
lcd.setCursor(0,2);
lcd.print("20x4 LCD Display");
lcd.setCursor(0,3);
lcd.print("I2C Interface");
}/*--(end setup )---*/
void loop()
{
}
沒有留言:
張貼留言