|
不管是FALLING,RISING,CHANGE,输出为什么都一样
unsigned long time1 = 0;
unsigned long time2 = 0;
int pin = 2;
int i = 0;
unsigned long t1 = 0, t2 = 0;// 时间标记
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pin,INPUT);
attachInterrupt(0,Code,FALLING);//中断种类换成RISING,CHANGE,结果都一样,是不是板子坏了???
}
void loop() {
// put your main code here, to run repeatedly:
}
void Code()
{
t1 = millis();
if((t1-t2)>10)
{
Serial.print(i);
Serial.println("zhongduan");
i++;
}
t2 = millis();
} |
|