:::

7-2 LCD跑馬燈

一、實作練習

顯示 hello!左右來回跑馬燈

#include <Wire.h>  // Arduino IDE 內建
#include <LiquidCrystal_I2C.h>

// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() 
{
   lcd.begin(16,2);    
}   
void loop() 
{
  lcd.setCursor(0,0);
  lcd.print("hello!"); 
  for(int i=0;i<10;i++)
  {
   lcd.scrollDisplayRight();
    delay(200);
  }
  for(int i=0;i<10;i++)
  {
   lcd.scrollDisplayLeft();
   delay(200);
  }
}

 

二、練習

1. 設計 Arduino 程式,控制 LCD 顯示"hello!",並且由左向右移動。

2. 設計 Arduino 程式,控制 LCD 顯示"hello!",並且由右向左移動。

3. 控制LCD顯示”hello!”,讓其可以呈口字型移動。
 


搜尋