int bpm;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0); // Arduino reading the ECG values
float voltage= sensorValue*(7.5/1023.0); // To change the reading up to 5V
Serial.println(voltage);
if (voltage <= 5){
bpm=1;
delay (3000);
Serial.print (bpm);
}
}
So, this is what I have an it's kinda showing the ECG. I have attached the picture.
However, when I'm trying to show it on my LCD and do the calculations, it's not working. This is the code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27, 16,2);
int bpm=0;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
lcd.init ();
lcd.backlight ();
lcd.print ("MACHA ECG"); // show company name
}
void loop() {
int sensorValue = analogRead(A0); // Arduino reading the ECG values
float voltage= sensorValue*(7.5/1023.0); // To change the reading up to 5V
Serial.println(voltage);
do {
if (voltage >= 5.0){ // read the value what comes from the serial plotter and make the comparation
bpm= bpm+1; // if the voltage is more than 5V it will count as a heart beat
delay (3000);
}continue;
}while (bpm*6);
lcd.display();
lcd.setCursor(0,3);
lcd.write(1);
if (bpm>= 100){
lcd.print("Sinus Tachycardia");
return;
} else if (bpm <= 60){
lcd.print ("Sinus Bradycardia");
return;
} else{
lcd.print ("Normal Sinus");
return;
}
Please advise. I’m using a wire from the ECG directly to the patient simulator.