|
求助各位坛友帮我指点下是照官网教程八做触控灯失败了,
#include < CapacitiveSensor.h >
//create on instance of the CapacitiveSensor library
//and identify what pins it will use
//pin 4 is the send pin,pin 2 is the sensor pin
CapacitiveSensor CapSensor = CapacitiveSensor (4,2);
int threshold=1000;
const int ledPin=12;
void setup()
{
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop()
{
long sensorVolue= capSensor.CapacitiveSensor(30);
Serial.println(sensorVolue);
if(sensorVolue>threshold)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
delay(10);
} |
|