“四按键”的版本间的差异
来自Labplus盛思维基百科
Tangliufeng(讨论 | 贡献) |
Jiangzhaohui(讨论 | 贡献) (→使用教程) |
||
第36行: | 第36行: | ||
| 按下D按键 || 700-800 | | 按下D按键 || 700-800 | ||
|} | |} | ||
+ | === Arduino示例 === | ||
+ | <pre style="color:blue"> | ||
+ | //程序功能:读取四按键当前的采样值// | ||
+ | int fourbottonPin =A0; | ||
+ | int val; | ||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | pinMode(fourbottonPin, INPUT); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
+ | val=analogRead(fourbottonPin); | ||
+ | Serial.println(val); | ||
+ | } | ||
+ | </pre> |
2018年1月8日 (一) 10:23的版本
概述
该集成4个按压式按键,只需1个引脚连接便可获取4个按键状态,节省主控I/O资源。当某个按键按下时,AO输出相应的模拟量。
技术参数
- 工作电压:VCC 3.3-5V
- 集成4个按键,只需1引脚资源
- 模块尺寸:24x46x7.5mm
引脚定义
VCC | 电源 |
NC | 空脚 |
AO | 模拟输出 |
GND | 地 |
使用教程
AO输出模拟量0~1023,可通过analog Read,检测4按键状态。
按键状态 | AO模拟量 |
---|---|
4个按键都不按 | >1000 |
按下A按键 | 0-50 |
按下B按键 | 200-300 |
按下C按键 | 450-550 |
按下D按键 | 700-800 |
Arduino示例
//程序功能:读取四按键当前的采样值// int fourbottonPin =A0; int val; void setup() { Serial.begin(9600); pinMode(fourbottonPin, INPUT); } void loop() { // put your main code here, to run repeatedly: val=analogRead(fourbottonPin); Serial.println(val); }