ocrobot:alpha:1602:tutorial07
| 前一修订版 |
— | ocrobot:alpha:1602:tutorial07 [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1 |
---|
| |
| ====== 屏幕滚动====== |
| |
| <WRAP left round info 60%> |
| 这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上滚动屏幕。 |
| </WRAP> |
| |
| |
| |
| ==== 硬件 ==== |
| * [[ocrobot:alpha:parallelexpansion:index|ALPHA 并行扩展板]] |
| * [[ocrobot:alpha:mega328-u:main|ALPHA MEGA328-U]] |
| * [[ocrobot:alpha:1602:main|ALPHA 1602 LCD模块]] |
| |
| ==== 搭建电路 ==== |
| |
| - ALPHA 1602 LCD模块插入并行扩展版1号槽位。 |
| - ALPHA MEGA328-U模块插入并行扩展板2号槽位。 |
| - USB线连接计算机与ALPHA MEGA328-U。 |
| {{:ocrobot:alpha:1602:1602无显示435.png?nolink|}} |
| ==== 代码 ==== |
| <code cpp> |
| #include <Wire.h> |
| #include <LiquidCrystal_I2C.h> |
| LiquidCrystal_I2C lcd(0x20,16,2); |
| void setup() { |
| lcd.init(); |
| lcd.backlight(); |
| lcd.print("hello, world!"); |
| delay(1000); |
| } |
| |
| void loop() { |
| // 向左滚动字符到屏左边边缘: |
| for (int positionCounter = 0; positionCounter < 13; positionCounter++) { |
| lcd.scrollDisplayLeft(); |
| delay(150); |
| } |
| |
| //向右滚动到屏右边边缘 |
| for (int positionCounter = 0; positionCounter < 29; positionCounter++) { |
| lcd.scrollDisplayRight(); |
| delay(150); |
| } |
| |
| // 向左滚动 |
| for (int positionCounter = 0; positionCounter < 16; positionCounter++) { |
| lcd.scrollDisplayLeft(); |
| delay(150); |
| } |
| |
| delay(1000); |
| |
| } |
| |
| </code> |
| |
| |
| [[ocrobot:alpha:1602:main|返回上一级]] |