Pls help me!! I can't seem to get setcursor to work. My bar graph keeps overlapping "This is your heartbeat" at the first line on the LCD screen.
#include <LiquidCrystal.h>
#include <LcdBarGraph.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //LiquidCrystal lcd(RS, Enable, D4, D5, D6, D7)
LcdBarGraph lbg(&lcd, 20); // -- creating
// Variables
int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0 (A0)
int blinkPin = 13; // pin to blink led at each beat
byte lcdNumCols = 20; // -- number of columns in the LCD
// These variables are volatile because they are used in the interrupt service routine!
volatile int BPM; // int that holds the pulse rate. updated every 2mS
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".
volatile boolean QS = false; // becomes true when Arduoino finds a beat.
int temp;
int count = 0;
void setup(){
lcd.begin(4, 20);
pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!
interruptSetup(); // sets up to read Pulse Sensor signal every 2mS
void loop() {
lcd.print("Time for your regular checkup!");
delay(3000);
lcd.clear();
for (int i = 0; i < 1000; i++){
lcd.setCursor(0,0);
lcd.print("This is your hearbeat: ");
lcd.print(BPM);
lcd.setCursor(1,3);
lbg.drawValue(BPM, 200);
temp = BPM;
delay(1000);
for (int j = 0; j < 1500; j++){
if (BPM == temp){
count = count + 1;
delay(1);
}
}
if (count == 1500){
lcd.clear();
lcd.print("No heartbeat detected");
delay(5000);
lcd.clear();
count = 0;
}
else if (BPM >100 || BPM < 30){
count = 0;
break;
}
delay(1000);
lcd.clear();
count = 0;
}
lcd.clear();
if (BPM < 30){
lcd.print("Your heartbeat is too low! BPM: ");
lcd.print(BPM);
delay(5000);
lcd.clear();
}
if (BPM > 100){
lcd.print("Your heartbeat is too high! BPM: ");
lcd.print(BPM);
delay(5000);
lcd.clear();
}