scrollDisplayLeft()
描述
将显示内容(文本和光标)向左滚动一格
语法
lcd.scrollDisplayLeft()
参数
lcd: LiquidCrystal实例化对象
示例程序
电路连接见电路连接
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /**********************************************************************   程序名称/Program name     : scrollDisplayLeft_scrollDisplayRight   团队/Team                 : 太极创客团队 / Taichi-Maker (www.taichi-maker.com)   作者/Author               : Dapenson   日期/Date(YYYYMMDD)     : 2020/06/16   程序目的/Purpose          :   演示使用scrollDisplayLeft和scrollDisplayRight函数将LCD显示的内容进行指定方向的滚动   -----------------------------------------------------------------------   修订历史/Revision History   日期/Date    作者/Author      参考号/Ref    修订说明/Revision Description   ----------------------------------------------------------------------- ***********************************************************************/ #include <LiquidCrystal.h> // 创建lcd控制对象,并指定其引脚与Arduino控制板对应关系 const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() {   // lcd初始化,同时设置lcd屏幕的列数和行数(宽和高)   lcd.begin(16, 2);   //   向LCD打印"hello, world!"   lcd.print("hello, world!"); } void loop() {   //向左滚动13个位置(即字符串长度)   //将其向屏幕外移动:   for (int positionCounter = 0; positionCounter < 13; positionCounter++) {     // 向左滚动一格     lcd.scrollDisplayLeft();     //延时150毫秒     delay(500);   }   // 向右滚动29个位置(字符串长度13+显示长度16)   // 向右滚动出屏幕   for (int positionCounter = 0; positionCounter < 29; positionCounter++) {     //滚动一格单位     lcd.scrollDisplayRight();     // 些许延时     delay(500);   }   // 向左滚动16个位置(显示长度)   // 移动回中心   for (int positionCounter = 0; positionCounter < 16; positionCounter++) {     // 向左滚动一格     lcd.scrollDisplayLeft();     // 稍微延迟以更好的显示效果     delay(500);   }   // 在循环结束时延时   delay(1000); } | 
效果演示
