我的串行端口没有正确显示传感器数据



嘿,我的Arduino和传感器有点问题
这是我试过的;

#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.
#include <SoftwareSerial.h>
SoftwareSerial blue(0,1);
const int PulseWire = 0;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13;          // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; 
PulseSensorPlayground pulseSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
blue.begin(9600);
pulseSensor.analogInput(PulseWire);   
pulseSensor.blinkOnPulse(LED13);       //auto-magically blink Arduino's LED with heartbeat.
pulseSensor.setThreshold(Threshold);
pulseSensor.begin();
}
void loop() {

// put your main code here, to run repeatedly:
int myBPM = pulseSensor.getBeatsPerMinute();
if(myBPM>200){
myBPM-100;
}
if (pulseSensor.sawStartOfBeat()) {
Serial.println(myBPM);
blue.println(myBPM);
}
delay(10);
}

这段代码是我从示例库中得到的,并对其进行了修改。
所以我想用蓝牙把数据发送到我的安卓系统,但这个传感器有点让我生气,因为每当我把它和HC-06蓝牙模块一起使用时,它都会突然发出砰砰的声音,我甚至没有碰它,它只是发送了太多数据,忽略了我设置的延迟
我只需要像一秒钟一样慢慢发送数据,但数据没有显示
所以有人可以帮忙吗?

我阅读了您的代码,注意到了这段代码if(myBPM > 200){ myBPM - 100; }如果(我理解正确(你想检查myBPM的大小,如果它大于200,那么应该减去100。它应该是:myBPM = myBPM - 100;而非myBPM - 100;我希望我的回答能对你有所帮助。祝你今天愉快!

最新更新