ocrobot:alpha:1602:tutorial01
文字滚动
这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上滚动文字。
硬件
搭建电路
- ALPHA 1602 LCD模块插入并行扩展版1号槽位。
- ALPHA MEGA328-U模块插入并行扩展板2号槽位。
- USB线连接计算机与ALPHA MEGA328-U。
代码
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x20,16,2); void setup() { lcd.init(); //初始化 lcd.backlight();//开背光 } void loop() { //设置光标位置为(0,0): lcd.setCursor(0, 0); // 显示0到9: for (int thisChar = 0; thisChar < 10; thisChar++) { lcd.print(thisChar); delay(500); } // 设置光标 (16,1): lcd.setCursor(16, 1); // 移动: lcd.autoscroll(); // 显示0到9: for (int thisChar = 0; thisChar < 10; thisChar++) { lcd.print(thisChar); delay(500); } //停止移动 lcd.noAutoscroll(); // 清屏: lcd.clear(); }
ocrobot/alpha/1602/tutorial01.txt · 最后更改: 2023/06/07 04:23 由 127.0.0.1