小羊同学 发表于 2015-4-14 21:01:08

怎么从某个时刻开始能进入中断

如题,比如在setup里面写了一个中断,怎么让在2s之后才开始能够执行?谢啦{:soso_e100:}

microplc 发表于 2015-4-14 21:12:37

建议看看scoop。

suoma 发表于 2015-4-15 09:56:03

loop里面调用该函数

林定祥 发表于 2015-4-15 14:12:06

一定需要中断吗?简单的程序在loop中可以不断检查时间差,到点再触发事件。

tsaiwn 发表于 2015-4-16 12:51:17

什么叫做 在setup里面写了一个中断 ?
中断程序怎可写在 setup( ) 内 ?
如果你意思是 attach 的 外部中断,
希望在进入 loop( ) 内过两秒才启动中断:
int yesInt = 0;
unsigned long now = 0;
unsigned long after = 2*1000; // 2 秒后
void setup( ) {
///..
now = millis( );
}
void loop( ) {
   if(yesInt == 0) checkInt( );
   //... your code
}
void checkInt( ) {
   if(millis( ) - now < after) return;
   yesInt = 1; // indicate interrupt is enabled
   // 启动中断
   attachInterrupt( ... );
}
页: [1]
查看完整版本: 怎么从某个时刻开始能进入中断