博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Arduino 4X3键盘 AD模拟分量实现
阅读量:6220 次
发布时间:2019-06-21

本文共 1867 字,大约阅读时间需要 6 分钟。

//读分量测试----------------int keyboardPin = 0;    //模拟口0 int keyboardValue = 0;   // 取得键AD模拟分量 void setup() {   //通信波特率   Serial.begin(9600);  } void loop() {   keyboardValue = analogRead(keyboardPin); // read the pot value     Serial.println(keyboardValue);      // 串口打印   delay(1000);                   }---------------------------------------------------------int keypressed = 0;int keyboardPin = 0;    int keyboardValue = 0;  void setup(){  Serial.begin(9600); }void loop(){  keyboardValue = analogRead(keyboardPin); //AD分量范围2的10次方 while (keyboardValue < 25){   //监听模拟口 keyboardValue = analogRead(keyboardPin);  delay(50);              readkeyboard();  }void readkeyboard(){   keyboardValue = analogRead(keyboardPin);   if (keyboardValue <25){keypressed = 0;}   if ((keyboardValue >25) && (keyboardValue < 67)){keypressed = 1;}   if ((keyboardValue >67) && (keyboardValue < 108)){keypressed = 2;}   if ((keyboardValue >108) && (keyboardValue < 162)){keypressed = 3;}   if ((keyboardValue >162) && (keyboardValue < 253)){keypressed = 4;}   if ((keyboardValue >253) && (keyboardValue < 361)){keypressed = 5;}   if ((keyboardValue >361) && (keyboardValue < 479)){keypressed = 6;}   if ((keyboardValue >479) && (keyboardValue < 619)){keypressed = 7;}   if ((keyboardValue >619) && (keyboardValue < 765)){keypressed = 8;}   if ((keyboardValue >765) && (keyboardValue < 819)){keypressed = 9;}   if ((keyboardValue >819) && (keyboardValue < 889)){keypressed = 0;}   if ((keyboardValue >889) && (keyboardValue < 938)){keypressed = 0;}   if (keyboardValue >938){keypressed = 0;}   while (keyboardValue > 25) {     delay (100);     keyboardValue = analogRead(keyboardPin);   }   Serial.println(keypressed);        delay(1000);                                         }
View Code

 

posted on
2015-10-30 14:39 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/darkdance/p/4923230.html

你可能感兴趣的文章
【转】FlashBack总结之闪回查询与闪回表
查看>>
python的多态
查看>>
alpha阶段总结
查看>>
js友好提示是否继续,post提交
查看>>
文本框,下拉框,单选框只读状态属性
查看>>
js 中for循环和indexOf()性能对比
查看>>
【leetcode】934. Shortest Bridge
查看>>
String[]遍历
查看>>
03、书店寻宝(二)
查看>>
个人作业报告
查看>>
团队绩效管理
查看>>
docker - 常用命令
查看>>
匿名函数应用2 eval
查看>>
zookeeper配置详解
查看>>
使用jQuery中trigger()方法自动触发事件
查看>>
[问题排查]记录一次两个dubbo提供者同时在线,代码不一致导致问题的排查记录...
查看>>
ddd
查看>>
数据仓库一些整理(列式数据库)【转】
查看>>
load & get 加载方式
查看>>
犯罪分析制图
查看>>