// ====================================================
// ArduExams Copyright(C) 2018 Furkan Türkal
// This program comes with ABSOLUTELY NO WARRANTY; This is free software,
// and you are welcome to redistribute it under certain conditions; See
// file LICENSE, which is part of this source code package, for details.
// ====================================================
#include <LiquidCrystal.h>
#define BTN_LCD_RIGHT 0
#define BTN_LCD_UP 1
#define BTN_LCD_DOWN 2
#define BTN_LCD_LEFT 3
#define BTN_LCD_SELECT 4
#define BTN_LCD_NONE 5
LiquidCrystal lcd(0, 1, 4, 5, 6, 7);
int LCD_KeyValue = 0;
int LCD_KeyIn = 0;
int LCD_CurrentX = 0;
int LCD_CurrentY = 0;
void setup() {
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(1,1);
lcd.print("A");
Serial.begin(9600);
}
void loop() {
LCD_CurrentX = constrain(LCD_CurrentX, 0, 16);
LCD_CurrentY = constrain(LCD_CurrentY, 0, 2);
lcd.clear();
lcd.setCursor(LCD_CurrentX, LCD_CurrentY);
lcd.print("A");
LCD_KeyValue = readLCDButtons();
switch(LCD_KeyValue){
case BTN_LCD_UP:
LCD_CurrentY++;
break;
case BTN_LCD_DOWN:
LCD_CurrentY--;
break;
case BTN_LCD_LEFT:
LCD_CurrentX--;
break;
case BTN_LCD_RIGHT:
LCD_CurrentX++;
break;
}
delay(10);
}
int readLCDButtons(){
LCD_KeyIn = analogRead(0);
if (LCD_KeyIn > 1000) return BTN_LCD_NONE;
if (LCD_KeyIn < 50) return BTN_LCD_RIGHT;
if (LCD_KeyIn < 195) return BTN_LCD_UP;
if (LCD_KeyIn < 380) return BTN_LCD_DOWN;
if (LCD_KeyIn < 555) return BTN_LCD_LEFT;
if (LCD_KeyIn < 790) return BTN_LCD_SELECT;
return BTN_LCD_NONE;
}
- 序言
- 第一章 arduino简介和学习
- 第一节 arduino介绍
- 第二节 学习方法概述
- 第三节 计算机的智能
- 第二章 开始学习之旅
- 第一节 安装环境和购买硬件的说明
- 第二节 介绍一个具体的范例
- 第三章 分类官网教程讲解
- 第一节 Basics类的示例项目
- 第二节 数字端口的示例
- 第三节 模拟端口的示例
- 第四节 串口通信的示例
- 第五节 LED显示的示例
- 第六节 arduino处理矩阵键盘
- 第七节 LCD显示范例
- 第四章 综合实践项目制作教程
- 第一节 简单的计算器
- 第五章 复习题
- 单选题
- 编程题目
- 单选题答案
- 编程题答案
- 第1题
- 第2题
- 第3题
- 第4题
- 第5题
- 第6题
- 第7题
- 第8题
- 第9题
- 第10题
- 第11题
- 第12题
- 第13题
- 第14题
- 第15题
- 第16题
- 第17题
- 复习题包含翻译
- 第六章 快速复习
- 第一节 英文解说