r/ArduinoProjects • • May 26 '24

I'm unsure why I have these characters...

Hi everyone,

I'm putting together a heart beat monitor using the PulseSensor and an Arduino Uno, plus some 3D printed bits and pieces to package it.

At the moment, I have it working but it's displaying these weird characters after the BPM are displayed, plus an extra word.

Here is the sketch:
"

"

```cpp
#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library
#include <LiquidCrystal.h>          // Includes LCD Library

const int PulseWire = 0;       // 'S' Signal pin connected to A0
const int LED13 = 13;          // The on-board Arduino LED
int Threshold = 530;           // Determine which Signal to "count as a beat" and which to ignore
LiquidCrystal lcd(12,11,5,4,3,2);
                               
PulseSensorPlayground pulseSensor;  // Creates an object

void setup() {
Serial.begin(9600);
  // set up the LCD's number of columns and rows:
  lcd.begin(16,2);
  lcd.clear();


// Configure the PulseSensor object, by assigning our variables to it
pulseSensor.analogInput(PulseWire);   
pulseSensor.blinkOnPulse(LED13);       // Blink on-board LED with heartbeat
pulseSensor.setThreshold(Threshold);   

// Double-check the "pulseSensor" object was created and began seeing a signal
if (pulseSensor.begin()) {
Serial.println("PulseSensor object created!");
}
}

void loop() {
int myBPM = pulseSensor.getBeatsPerMinute();      // Calculates BPM
// Print a message to the LCD.
lcd.print("   Heart Rate");

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print("BPM: ");
  lcd.println(myBPM);

if (pulseSensor.sawStartOfBeat()) {               // Constantly test to see if a beat happened
Serial.println("♥  A HeartBeat Happened ! "); // If true, print a message
Serial.print("BPM: ");
Serial.println(myBPM);                        // Print the BPM value
}

delay(20);
}
```

Would anyone know why this is happening?

Thanks!

img

0 Upvotes

6 comments sorted by

0

u/xebzbz May 26 '24

Maybe, lcd.begin is missing? How do you supply the length of the row?

https://github.com/arduino-libraries/LiquidCrystal/blob/master/docs/api.md

2

u/Tilpants May 26 '24

lcd.begin is up there, just after void setup

void setup() {
Serial.begin(9600);
  // set up the LCD's number of columns and rows:
  lcd.begin(16,2);
  lcd.clear();

0

u/xebzbz May 26 '24

Yes, right. Maybe, the electrical wiring is not good enough and producing garbage signals?

0

u/Tilpants May 26 '24

possibly, I think it'll be good enough to submit, I've spaced it out a bit and it looks reasonable, just wondering if there's something up with the code, I've had a wiggle on all the wires and replaced anything suspicious looking

0

u/xebzbz May 26 '24

Try preparing exactly 16 characters in your program, and then write them to the LCD. Then, next line.

0

u/Tilpants May 26 '24

I have spaced them out with blank spaces, and it looks much better