玄冰之神 发表于 2013-7-8 16:52:52

咨询外部中断问题

纠结了一下午 我用attachInterrupt();函数利用上升沿中断,我用来测量人体的脉冲信号,最蛋疼的一点 ,脉冲时间来的时候很突然,就是你不知道什么时候来一个脉冲。我要做模数转换。假设每3毫秒计数一次,当下一个脉冲来的时候我的计数就玩完了。

玄冰之神 发表于 2013-7-8 16:57:16



void setup()
{
Serial.begin(9600);
attachInterrupt(0, readtimes, RISING);
}

void readtimes()
{
int time=0;
double num = 0;
if(下一个脉冲之前) //就是这的处理关系 我想不明白了
{
int n = analogRead(A0);
double vol = n * (5 / 1024.0 * 100);
num+=vol;
time++;
delay(10);
}
double average= num/time;
if(average>3)
{
Serial.println(average);
}
}

void loop()
{
}

qptimus 发表于 2013-7-8 21:13:48

不明白你要问什么

hp198969 发表于 2013-7-8 22:45:38


noInterrupts()
interrupts()
在中断需要运行的程序前后加上这两个就行了。
前一个表示禁用中断
后一个表示启用中断
页: [1]
查看完整版本: 咨询外部中断问题