本站改版新增arduino频道
arduino 触摸按键控制led
int ledPin = 13; // Connect LED on pin 13, or use the onboard one int KEY = 2; // Connect Touch sensor on Digital Pin 2 void setup(){ pinMode(ledPin, OUTPUT); // Set ledPin to output mode pinMode(KEY, INPUT); //Set touch sensor pin to input mode } void loop(){ if(digitalRead(KEY)==HIGH){ //Read Touch sensor signal digitalWrite(ledPin, HIGH); // if Touch sensor is HIGH, then turn on }else{ digitalWrite(ledPin, LOW); // if Touch sensor is LOW, then turn off the led } }
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0094978809356689 seconds