gpt4 book ai didi

无法从 ECG 检索数据 - Arduino

转载 作者:行者123 更新时间:2023-12-04 11:59:13 25 4
gpt4 key购买 nike

您好 StackOverflow 社区,

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

1

这是我的代码:

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! ");
}
}

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

最佳答案

在电流通过 LED 后,您似乎在引脚 5 读取电压。 LED 会产生电压降,因此电压可能永远不会高到无法在 digitalRead() 调用中注册为高电压。也许改变了您对电压进行采样的位置,或者尝试使用 analogRead() 代替。

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

关于无法从 ECG 检索数据 - Arduino,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27595354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com