用户工具

站点工具


ocrobot:alpha:1602:tutorial09

显示A到Z

这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上显示A到Z。

硬件

搭建电路

  1. ALPHA 1602 LCD模块插入并行扩展版1号槽位。
  2. ALPHA MEGA328-U模块插入并行扩展板2号槽位。
  3. USB线连接计算机与ALPHA MEGA328-U。

代码

const int numRows = 2;
const int numCols = 16;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,numCols,numRows); 
 
void setup() {
  lcd.init();
  lcd.backlight();
}
 
void loop() {
  // 'a' 到 'z'循环:
  for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
    // 行循环:
    for (int  thisRow = 0; thisRow < numRows; thisRow++) {
      // 列循环:
      for (int thisCol = 0; thisCol < numCols; thisCol++) {
        // 设置光标位置:
        lcd.setCursor(thisCol, thisRow);
        // 显示字符:
        lcd.write(thisLetter);
        delay(200);
      }
    }
  }
}

返回上一级

ocrobot/alpha/1602/tutorial09.txt · 最后更改: 2023/06/07 04:23 由 127.0.0.1