Arduino Touch_Switch_Module

Touch Switch Module
The touch switch module requires 4 pins to connected to the Arduino board as input and 2 pins for Vcc and Gnd.
The touch sensor module has 4 sensor pads with LED diode that shows whether sensor pad is touched.
Each touch sensor pad has its own value as below:The following code will show the touched pad value (1, 2, 3 or 4).

You can also try touching multiple pads at the same time.

bool switch1 = false;
bool switch2 = false;
bool switch3 = false;
bool switch4 = false;

void setup() 
{
  Serial.begin(9600);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
}

void loop() 
{
  getSwitchSettings();
  Serial.print("Switches On:");
  if(switch1) Serial.print(" 1");
  if(switch2) Serial.print(" 2");
  if(switch3) Serial.print(" 3");
  if(switch4) Serial.print(" 4");
  Serial.println();
  delay(200);
}

void getSwitchSettings()
{
  if(digitalRead(8)) switch1 = true;
  else switch1 = false;
  if(digitalRead(9)) switch2 = true;
  else switch2 = false;
  if(digitalRead(10)) switch3 = true;
  else switch3 = false;
  if(digitalRead(11)) switch4 = true;
  else switch4 = false;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,504评论 0 10
  • It's Thursday. Four Harry Cat Chester buried his head in ...
    Mr_Oldman阅读 392评论 0 0
  • 一般来说,元宵节是吃汤圆的,而我们这儿是喝粥的。 元宵节的粥,叫通心粥。用新年剩下的鸡头、鸡爪熬粥,寓意着聪明伶俐...
    余霞散成绮阅读 1,121评论 0 0
  • 在某个同样寂静的晚上,耳边依旧是熟悉的车流声,关上房门,感受指尖的凉意,此刻,是凌晨00:30,可是并未有一丝睡意...
    抹茶蔷薇阅读 159评论 0 0
  • 每天的生活都大部分重复着,偶尔出去吃吃喝喝玩玩,那么对你来说最好吃的食物排名是什么呢?最可口的饮品是哪些呢?最好逛...
    小泥巴教练阅读 209评论 0 0