怎么从某个时刻开始能进入中断
如题,比如在setup里面写了一个中断,怎么让在2s之后才开始能够执行?谢啦{:soso_e100:} 建议看看scoop。 loop里面调用该函数 一定需要中断吗?简单的程序在loop中可以不断检查时间差,到点再触发事件。 什么叫做 在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]