|
|
LCD1602 Arduino 電位器
VSS → GND
VDD → 5V
VO → 電位器中腳
RS → 12
E → 11
D4-D7 → 5,4,3,2
A → 5V(背光)
K → GND
電位器左腳 → 5V
電位器中腳 → LCD VO
電位器右腳 → GND- #include <LiquidCrystal.h>
- // 初始化LCD,設(shè)置接口引腳
- // RS, E, D4, D5, D6, D7
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- void setup() {
- // 設(shè)置LCD的列數(shù)和行數(shù)(16列2行)
- lcd.begin(16, 2);
-
- // 打印初始信息
- lcd.print("Hello, World!");
-
- // 將光標(biāo)移動(dòng)到第二行第一個(gè)位置
- lcd.setCursor(0, 1);
- lcd.print("LCD1602 Test");
-
- delay(2000); // 顯示2秒
- }
- void loop() {
- // 清屏
- lcd.clear();
-
- // 顯示靜態(tài)文本
- lcd.print("Arduino LCD");
- lcd.setCursor(0, 1);
- lcd.print("Welcome!");
-
- delay(2000);
-
- // 顯示滾動(dòng)文本
- lcd.clear();
- lcd.print("Scrolling Text");
- for (int position = 0; position < 13; position++) {
- lcd.scrollDisplayLeft();
- delay(300);
- }
-
- delay(1000);
-
- // 顯示計(jì)數(shù)
- lcd.clear();
- lcd.print("Counter:");
- for (int i = 0; i <= 10; i++) {
- lcd.setCursor(0, 1);
- lcd.print("Count: ");
- lcd.print(i);
- delay(500);
- }
-
- delay(1000);
- }
復(fù)制代碼
|
評(píng)分
-
查看全部評(píng)分
|