qianqifeng 发表于 2016-10-16 21:06:33

外部中断种类

不管是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();
}

qianqifeng 发表于 2016-10-16 21:14:07

在没有外接电路下,把手靠近Pin2的引脚都能触发中断,这的怎么回事????
页: [1]
查看完整版本: 外部中断种类