標(biāo)題: arduino使用LiquidCrystal庫(kù)在lcd1602上滾動(dòng)顯示 [打印本頁(yè)]

作者: 寄語(yǔ)    時(shí)間: 2023-7-28 00:22
標(biāo)題: arduino使用LiquidCrystal庫(kù)在lcd1602上滾動(dòng)顯示
arduino可以使用liquidcrystal庫(kù)再lcd1602上顯示,也可以自行編輯指令顯示,此處使用的是liquidcrystal庫(kù),使用liquidcrystal庫(kù)更加簡(jiǎn)單明了,自行編輯命令更加復(fù)雜,但是自行編輯命令更加有助于對(duì)lcd1602的理解。
代碼如下:
#include <LiquidCrystal.h>

// 創(chuàng)建lcd控制對(duì)象,并指定其引腳與Arduino控制板對(duì)應(yīng)關(guān)系
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// 定義一個(gè)'a'變量
int thisChar = 'a';

void setup()
{
  // lcd初始化,同時(shí)設(shè)置lcd屏幕的列數(shù)和行數(shù)(寬和高)
  lcd.begin(16, 2);
  // 打開光標(biāo)
  lcd.cursor();
}

void loop()
{
  //在'm'處轉(zhuǎn)向
  if (thisChar == 'm')
  {
    // go right for the next letter
    lcd.rightToLeft();
  }
  // 在's'處再次反轉(zhuǎn)
  if (thisChar == 's')
  {
    // 向左走到下一個(gè)字母
    lcd.leftToRight();
  }
  // 大于'z'則重置
  if (thisChar > 'z')
  {
    // 回到(0,0)位置:
    lcd.home();
    //再次從a開始
    thisChar = 'a';
  }
  // 打印字符
  lcd.write(thisChar);
  // 延時(shí)等待一秒
  delay(100);
  // thisChar自增
  thisChar++;
}
proteus接線圖如下:


作者: 寄語(yǔ)    時(shí)間: 2023-7-28 00:24
proteus工程和arduino項(xiàng)目分別在兩個(gè)包里

arduino_scrolling_show.rar

17.47 KB, 下載次數(shù): 10, 下載積分: 黑幣 -5

Proteus仿真

arduino and lcd1602 scrolling shouw.rar

62.64 KB, 下載次數(shù): 12, 下載積分: 黑幣 -5

程序


作者: 123456poiuytrew    時(shí)間: 2024-3-28 15:04
沒(méi)有工程
作者: sfls    時(shí)間: 2024-8-15 13:19
為什么我的1602不顯示呢?




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1