setcursors not working?? HELP

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();

}

It seems you expect a 20 x 4 LCD to work like a 4 x 20 LCD.

I don't know if the LiquidCrystal library lets you do that.

.

Yes I am using a 20 x 4 lcd. According to arduino website, LiquidCrystal allows the usage of setcursor, so I was suspecting that there is something wrong with the code? However, I can't seem to find the problem with the code.

  lcd.begin(4, 20);

The LiquidCrystal library reference for the begin function shows that the proper syntax is

lcd.begin(cols, rows);  // for a 20x4 display should be lcd.begin(20, 4)

I guess that's why the part numbers frequently contain the number 2004 and not 0420.

Same goes for the 16x2 configuration.

Don

I tried led.begin(20 x 4) but it’s still doesn’t work. The bar graph is still overlapping the sentence in the first row. However, I realised that the setcursor works for the sentences such as “this is your heartbeat” but it doesn’t work for the bargraph. Is there another code or fxn that applies to the bar graph and bring the bar graph down to the 4 row of the LCD screen?

Oh I was able to solve it. I saw another thread regarding the same problem! Thanks for your replies!

You should explain the fix here for others' sake and or link to that other thread.

Sorry! This is the thread that solve my problem - https://forum.arduino.cc/index.php?topic=369696.0
The problem did not lies with the setcursor but the code for LcdBarGraph display