I'm sharing my code.. The problem I am facing is that the code performs all the functions that are to be called except showing the MAX30100 (for heart rate) readings. I have tried this code using statement switches,cases, if-else but couldn't figure out. Can anyone help me out regarding this?
unsigned long runGSR() {
total = total - readings[index]; // subtract the last reading:
readings[index] = analogRead(inputPin); // read from the sensor:
delay(100);
total = total + readings[index]; // add the reading to the total:
index = index + 1; // advance to the next position in the
array:
if (index >= numReadings) //when the end of the array is reached
index = 0; // wrapped around to the beginning:
average = total / numReadings; // calculate the average:
return average; // send it to the computer as ASCII digits
}
void ambtemp()
{
reading = analogRead(A2); //takes the reading from analogue pin 2
tempVolts = reading * 5.0 / 1024.0; //converts the readings to volts
ambitemp = tempVolts / 0.01; //output voltage /10 millivolts = 1 degree
C
Serial.print(",Ambient Temp:"); //prints ambient temperature in serial monitor
Serial.println(ambitemp);
delay(10);
}
void hbt() //Function for heart rate (MAX30100) in which I am having problem
{
do
{
pox.update(); // Make sure to call update as fast as possible
if (millis() - tsLastReport > REPORTING_PERIOD_MS) { //the loop repeats every second
lcd.clear();
Serial.print("HR:");
Serial.println(pox.getHeartRate()); //prints Heart rate on LCD
delay(100);
ambtemp(); //calls the ambient temperature function
gsr = runGSR(); //calls the GSR sensor function
delay(100);
tsLastReport = millis();
}
}
Add them then usectrl+t
in ArduinoIDE to automatically format your code and then paste it again please. (Please use "code" function of the stackexchange editor to add code as code) – Filip Franik Feb 11 at 13:57Serial.println(pox.getHeartRate()); //prints Heart rate on LCD
.... the comment does not match the command – jsotola Feb 11 at 17:10