极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11322|回复: 1

外部中断种类

[复制链接]
发表于 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();
  }
回复

使用道具 举报

 楼主| 发表于 2016-10-16 21:14:07 | 显示全部楼层
在没有外接电路下,把手靠近Pin2的引脚都能触发中断,这的怎么回事????
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-5-4 00:49 , Processed in 0.042942 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表