用户工具

站点工具


ocrobot:alpha:1602:tutorial10

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
ocrobot:alpha:1602:tutorial10 [2017/10/04 04:03] 弘毅ocrobot:alpha:1602:tutorial10 [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1
行 1: 行 1:
  
 +====== 显示Z到A======
 +
 +<WRAP left round info 60%>
 +这个例程显示了如何在OCROBOT ALPHA 1602 LCD显示屏上显示Z到A。
 +</WRAP>
 +
 +
 +
 +==== 硬件 ====
 +  * [[ocrobot:alpha:parallelexpansion:index|ALPHA 并行扩展板]]
 +  * [[ocrobot:alpha:mega328-u:main|ALPHA MEGA328-U]]
 +  * [[ocrobot:alpha:1602:main|ALPHA 1602 LCD模块]]
 +
 +==== 搭建电路 ====
 +
 +  - ALPHA 1602 LCD模块插入并行扩展版1号槽位。
 +  - ALPHA MEGA328-U模块插入并行扩展板2号槽位。
 +  - USB线连接计算机与ALPHA MEGA328-U。
 +{{:ocrobot:alpha:1602:1602无显示435.png?nolink|}}
 +==== 代码 ====
 +
 +<code cpp>
 +#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++;
 +}
 +
 +</code>
 +
 +[[ocrobot:alpha:1602:main|返回上一级]]