// ====================================================
// 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.
// ====================================================
#define PIN_DATA A5
#define PIN_BUTTON 2
int DATA_Array[5] = {0, 0, 0, 0, 0};
int DATA_Counter = 0;
int DATA_Value = 0;
int BUTTON_State = LOW;
int BUTTON_State_Last = LOW;
void setup() {
pinMode(PIN_DATA, INPUT);
pinMode(PIN_BUTTON, INPUT);
Serial.begin(9600);
}
void printLast5DataToSerial(){
for (int i = 0; i < 5; i++){
Serial.print(DATA_Array[i]);
Serial.print(";");
}
Serial.println();
}
void loop() {
BUTTON_State = digitalRead(PIN_BUTTON);
DATA_Value = analogRead(PIN_DATA);
DATA_Array[0] = DATA_Array[1];
DATA_Array[1] = DATA_Array[2];
DATA_Array[2] = DATA_Array[3];
DATA_Array[3] = DATA_Array[4];
if(DATA_Counter != 4){
DATA_Array[DATA_Counter] = DATA_Value;
DATA_Array[4] = 0;
DATA_Counter++;
} else {
DATA_Array[DATA_Counter] = DATA_Value;
}
if(BUTTON_State && !BUTTON_State_Last){
printLast5DataToSerial();
delay(100);
}
BUTTON_State_Last = BUTTON_State;
delay(1000);
}
- 序言
- 第一章 arduino简介和学习
- 第一节 arduino介绍
- 第二节 学习方法概述
- 第三节 计算机的智能
- 第二章 开始学习之旅
- 第一节 安装环境和购买硬件的说明
- 第二节 介绍一个具体的范例
- 第三章 分类官网教程讲解
- 第一节 Basics类的示例项目
- 第二节 数字端口的示例
- 第三节 模拟端口的示例
- 第四节 串口通信的示例
- 第五节 LED显示的示例
- 第六节 arduino处理矩阵键盘
- 第七节 LCD显示范例
- 第四章 综合实践项目制作教程
- 第一节 简单的计算器
- 第五章 复习题
- 单选题
- 编程题目
- 单选题答案
- 编程题答案
- 第1题
- 第2题
- 第3题
- 第4题
- 第5题
- 第6题
- 第7题
- 第8题
- 第9题
- 第10题
- 第11题
- 第12题
- 第13题
- 第14题
- 第15题
- 第16题
- 第17题
- 复习题包含翻译
- 第六章 快速复习
- 第一节 英文解说