Intel物联网开发者专区
直播中

盼盼2333

9年用户 451经验值
擅长:可编程逻辑 连接器 电源/新能源 连接器 模拟技术 连接器 测量仪表 连接器 EMC/EMI设计 连接器 嵌入式技术 连接器 制造/封装 连接器 存储技术 连接器 连接器 接口/总线/驱动 连接器 处理器/DSP 连接器 光电显示 连接器 控制/MCU 连接器 EDA/IC设计 连接器 RF/无线 连接器 MEMS/传感技术 连接器
私信 关注
[经验]

【Intel Edison试用体验】9.Grove Touch 触摸按键的使用

根据Touch Sensor 的官网说明我们可以知道,它的使用和普通按键的输出是一样的,在触摸到的时候会像按键一样有一个返回一个高电平,手指拿开的时候又会返回低电平,和按键还有一个不同就是它有一个电源指示灯。
1468979373017.jpg

参考代码如下:
  1. #include
  2. #include
  3. #include "rgb_lcd.h"
  4. #include <timerOne.h>
  5. rgb_lcd lcd;
  6. Servo myservo;
  7. const int colorR = 255;
  8. const int colorG = 255;
  9. const int colorB = 255;

  10. const int thresholdvalue = 10 ;  //led trun on value
  11. const int timerInterval = 15 * 1000; //15ms

  12. const int APinTemp = 0;
  13. const int APinBright = 1;
  14. const int APinPot = 2;

  15. const int DPinLed = 2;
  16. const int DPinServo = 3;
  17. const int DPinKey = 4;
  18. const int DPinBuzzer = 5;
  19. const int DPinTouch = 7;
  20. void setup()
  21. {
  22.   //lcd.begin(16, 2);
  23.   //lcd.setRGB(colorR, colorG, colorB);
  24.   //lcd.setCursor(0, 0);
  25.   //lcd.print("temp:");
  26.   //lcd.setCursor(6, 1);
  27.   //lcd.print("panpan2333");
  28.   pinMode(DPinLed , OUTPUT);
  29.   //pinMode(DPinBuzzer , OUTPUT);
  30.   //pinMode(DPinKey , INPUT);
  31.   pinMode(DPinTouch, INPUT);
  32.   //myservo.attach(3);
  33.   //Timer1.initialize(timerInterval);
  34.   //Timer1.attachInterrupt( showLcd );
  35.   //attachInterrupt(DPinKey, interruptKeyControlLed, CHANGE);



  36. }


  37. void loop()
  38. {
  39.   if (digitalRead(DPinTouch))
  40.   {
  41.     digitalWrite(DPinLed, HIGH);
  42.   }
  43.   else
  44.   {
  45.     digitalWrite(DPinLed, LOW);
  46.   }
  47. }






回帖(1)

yu150232

2016-7-21 10:50:26
谢谢
举报

更多回帖

发帖
×
20
完善资料,
赚取积分