这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上显示Z到A。
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x20,16,2); int thisChar = 'a'; void setup() { lcd.init(); lcd.backlight(); lcd.cursor(); } void loop() { // 在'm'改变方向: if (thisChar == 'm') { // 向右 lcd.rightToLeft(); } // 在 's'返回: if (thisChar == 's') { // 向左 lcd.leftToRight(); } // 在'z'重来: if (thisChar > 'z') { // 返回 (0,0): lcd.home(); // 在 0 开始 thisChar = 'a'; } // 显示字符 lcd.write(thisChar); //等一秒: delay(1000); // 增加字符: thisChar++; }