这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上滚动文字。
#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(); }