这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版 | |||
ocrobot:alpha:1602:tutorial09 [2017/10/04 04:02] – 弘毅 | ocrobot:alpha:1602:tutorial09 [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== 显示A到Z====== | ||
+ | |||
+ | <WRAP left round info 60%> | ||
+ | 这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上显示A到Z。 | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== 硬件 ==== | ||
+ | * [[ocrobot: | ||
+ | * [[ocrobot: | ||
+ | * [[ocrobot: | ||
+ | |||
+ | ==== 搭建电路 ==== | ||
+ | |||
+ | - ALPHA 1602 LCD模块插入并行扩展版1号槽位。 | ||
+ | - ALPHA MEGA328-U模块插入并行扩展板2号槽位。 | ||
+ | - USB线连接计算机与ALPHA MEGA328-U。 | ||
+ | {{: | ||
+ | ==== 代码 ==== | ||
+ | |||
+ | <code cpp> | ||
+ | |||
+ | const int numRows = 2; | ||
+ | const int numCols = 16; | ||
+ | #include < | ||
+ | #include < | ||
+ | LiquidCrystal_I2C lcd(0x20, | ||
+ | |||
+ | void setup() { | ||
+ | lcd.init(); | ||
+ | lcd.backlight(); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // ' | ||
+ | for (int thisLetter = ' | ||
+ | // 行循环: | ||
+ | for (int thisRow = 0; thisRow < numRows; thisRow++) { | ||
+ | // 列循环: | ||
+ | for (int thisCol = 0; thisCol < numCols; thisCol++) { | ||
+ | // 设置光标位置: | ||
+ | lcd.setCursor(thisCol, | ||
+ | // 显示字符: | ||
+ | lcd.write(thisLetter); | ||
+ | delay(200); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | [[ocrobot: | ||