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;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,840評(píng)論 0 10
  • It's Thursday. Four Harry Cat Chester buried his head in ...
    Mr_Oldman閱讀 403評(píng)論 0 0
  • 一般來(lái)說(shuō),元宵節(jié)是吃湯圓的,而我們這兒是喝粥的。 元宵節(jié)的粥,叫通心粥。用新年剩下的雞頭、雞爪熬粥,寓意著聰明伶俐...
    余霞散成綺閱讀 1,241評(píng)論 0 0
  • 在某個(gè)同樣寂靜的晚上,耳邊依舊是熟悉的車流聲,關(guān)上房門,感受指尖的涼意,此刻,是凌晨00:30,可是并未有一絲睡意...
    抹茶薔薇閱讀 183評(píng)論 0 0
  • 每天的生活都大部分重復(fù)著,偶爾出去吃吃喝喝玩玩,那么對(duì)你來(lái)說(shuō)最好吃的食物排名是什么呢?最可口的飲品是哪些呢?最好逛...
    小泥巴教練閱讀 216評(píng)論 0 0

友情鏈接更多精彩內(nèi)容