首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法从ECG检索数据- Arduino

无法从ECG检索数据- Arduino
EN

Stack Overflow用户
提问于 2014-12-22 08:45:53
回答 1查看 1.2K关注 0票数 3

在StackOverflow社区,

在过去的几周里,我一直没有找到解决我的问题的方法。我的问题是,我无法从Arduino创建的自制ECG中检索数据。我在这方面完全是个外行,但我很确定这是电路问题。这是我的电路现在的样子。(注:最左边写着“双O”的是仪表放大器,而不是像中间那样的运算放大器)

下面是我的代码:

代码语言:javascript
运行
复制
const int  signal = 5;    // Pin connected to the filtered signal from the circuit
unsigned long currentBeatTime;   
unsigned long previousBeatTime;

unsigned long frequency;

// Internal variables
unsigned long period = 0;
int input = 0;
int lastinput = 0;


void setup() {
pinMode(signal, INPUT);
Serial.begin(9600);

previousBeatTime = millis();
}

void loop() {
delay(500);
input = digitalRead(signal);

if ((input != lastinput) && (input == HIGH)) {
    // If the pin state has just changed from low to high (edge detector)
    currentBeatTime = millis();

    period = currentBeatTime - previousBeatTime; // Compute the time between the previous beat and the one that has just been detected
    previousBeatTime = currentBeatTime; // Define the new time reference for the next period computing
}

lastinput = input; // Save the current pin state for comparison at the next loop iteration

// Detect if there is no beat after more than 2 seconds
if ( (millis() - previousBeatTime) > 2000 ) 
{ 
    Serial.println("dead");
}
else 
{
    if (period <= 0) 
    {
        frequency = 0;
    }
    else 
    {
        frequency = 60000/period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds
    }

    Serial.print(frequency);
    Serial.println(" : alive! ");
}
}

如果有人能尽快回复我,我将不胜感激。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2014-12-22 11:30:48

在电流通过LED之后,您看起来是在第5针上读取电压。LED会产生电压降,因此电压可能永远不会高到足以在digitalRead()调用中注册为高。可能更改了采样电压的位置,或者尝试使用analogRead()。

在任何情况下,您都需要确定这是一个与编程相关的问题,并将其发布在此板上。也许,electronics.stackexchange会提供更好的帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27595354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档