I modified the serial code in this way and I don't think the gap is produced by my edit even because it made it even before:
//////////
///////// All Serial Handling Code,
///////// It's Changeable with the 'serialVisual' variable
///////// Set it to 'true' or 'false' when it's declared at start of code.
/////////
void serialOutput(){ // Decide How To Output Serial.
if (serialVisual == true){
arduinoSerialMonitorVisual('-', Signal); // goes to function that makes Serial Monitor Visualizer
} else{
sendDataToSerial('S', Signal); // goes to sendDataToSerial function
}
}
// Decides How To OutPut BPM and IBI Data
void serialOutputWhenBeatHappens(){
if (serialVisual == true){ // Code to Make the Serial Monitor Visualizer Work
//ASCII Art Madness
Serial.print(BPM);
Serial.println("");
} else{
sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix
sendDataToSerial('Q',IBI); // send time between beats with a 'Q' prefix
}
}
// Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.
void sendDataToSerial(char symbol, int data ){
Serial.print(symbol);
Serial.println(data);
}
// Code to Make the Serial Monitor Visualizer Work
void arduinoSerialMonitorVisual(char symbol, int data ){
const int sensorMin = 0; // sensor minimum, discovered through experiment
const int sensorMax = 1024; // sensor maximum, discovered through experiment
int sensorReading = data;
// map the sensor range to a range of 12 options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 11);
// do something different depending on the
// range value:
switch (range) {
case 0:
Serial.println("");
}
}
63
63
63
63
63
62
62
62
62
62
62
62
63
62
63
64
63
63
64
64
65
65
65
68
74
78
86
95
105
112
123
141
167
154
136
128
123
125
123
127
132
104
93
92
92
89
83
77
73
69
65
70
70
71
You can find all the code here: https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino
In the code I posted there is some code I don'f find useful but I can't delete it for reason linked to variables used for other functions I don't know I'm using. You can also see huge changes in the heart rate that surely don't reflect the reality.
1 Answer 1
One of the possibilities is when you move your finger, the sensor grip loosened and doesn't count a "beat". So the sensor emits data = 0
, and it will cause
Serial.println("");
in your switch-case.
-
1Upvote because this seems most likely. If changing code doesn't matter, and the wiring is intact, then it must be the movement that is causing it. Like the old joke: "Doctor, it hurts when I lift my arm" and the Doctor says, "Then don't lift your arm"SDsolar– SDsolar2016年11月11日 01:51:13 +00:00Commented Nov 11, 2016 at 1:51
switch() case:
statement. Have a look at what theSerial.println('"");