Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法从ECG检索数据-Arduino_C_Arduino_Circuit - Fatal编程技术网

无法从ECG检索数据-Arduino

无法从ECG检索数据-Arduino,c,arduino,circuit,C,Arduino,Circuit,大家好,我的社区 在过去的几周里,我一直无法找到解决问题的办法。我的问题是,我无法从我从Arduino创建的自制ECG中检索数据。我在这方面完全是个业余爱好者,但我很确定这是一个电路问题。这是我的电路现在的样子。(注意:最左边显示“双O”的是仪表放大器,而不是像中间那个一样的运算放大器) 这是我的密码: const int signal = 5; // Pin connected to the filtered signal from the circuit unsigned lon

大家好,我的社区

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

这是我的密码:

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! ");
}
}
const int signal=5;//连接至电路滤波信号的针脚
无符号长时间;
长时间未签名;
无符号长频率;
//内部变量
无符号长周期=0;
int输入=0;
int lastinput=0;
无效设置(){
pinMode(信号、输入);
Serial.begin(9600);
previousBeatTime=millis();
}
void循环(){
延迟(500);
输入=数字读取(信号);
如果((输入!=lastinput)&&(输入==HIGH)){
//如果引脚状态刚从低变为高(边缘检测器)
currentBeatTime=millis();
period=currentBeatTime-previousBeatTime;//计算上一个节拍和刚刚检测到的节拍之间的时间
previousBeatTime=currentBeatTime;//为下一周期计算定义新的时间参考
}
lastinput=input;//保存当前管脚状态,以便在下一次循环迭代时进行比较
//检测超过2秒后是否没有跳动
如果((毫秒()-previousBeatTime)>2000)
{ 
序列号:println(“死亡”);
}
其他的
{

如果(period电流通过LED后,您似乎正在读取引脚5处的电压。LED会产生压降,因此电压可能永远不会高到足以在digitalRead()调用中记录为高。可能更改了电压采样点,或者改为尝试analogRead()


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

您是死了,还是吸血鬼?哈哈,不是,但我收到一个信号说我是。我只是以“死”作为输出。不过,请欣赏这个笑话。嗯,您是吗100%确信这不是一个硬件问题-示波器在输入引脚上显示信号,正确的引脚接线等?@user3744439:为了将来的参考,你需要学习如何绘制电子原理图。因为一个实验板的卡通图片是一个可怕的方式来传达你打算如何接线你的电路。据我们所知,问题可能是任何这里是信号链。换句话说:如果你将LED+电阻器连接到控制器板输入引脚,它会闪烁吗?嗨,UncleO,LED会工作。我不知道该怎么做。我问过EE,但我不理解他们的评论。