int buttonPin = 7; //接7号口
int buttonState = 0;
void setup() {
Serial.begin(9600);
pinMode (buttonPin,INPUT);
}
void loop() {
buttonState =digitalRead(buttonPin);
if (buttonState==HIGH)
{
delay(10);
if(buttonState == HIGH)
{ //电频跳动,时高时低,几毫秒之后再判断
Serial.println('1');
}
}
}
这里我下拉了一个10K电阻 |