I'm trying to build a simple device to monitor my heart rate. The components are the following:

  1. A TFT 2.8" LCD screen to display relevant information for the user.
  2. 3 buttons for the user to interact with the device.
  3. A PPG sensor to acquire the user's heartbeat.
  4. An Arduino Uno.
  5. A breadboard to connect the components.

The setup of the device looks like this:

enter image description here

which is connected in the following way:

enter image description here

I haven't included the TFT screen here in the drawing of the circuit because I'm using Tinkercad and they don't have it in the components. The screen has the following ports: enter image description here

The code that I'm using is the following:

// Heartbeat sensor libraries
#include <PulseSensorPlayground.h>

// TFT screen libraries
#include <TFT.h>  // Arduino LCD library

// Heartbeat sensor variables
const int PulseWire = 0; // PulseSensor WHITE WIRE connected to ANALOG PIN 0
int Threshold = 550; // Determine which Signal to "count as a beat"
PulseSensorPlayground pulseSensor; // Creates an instance of PulseSensorPlayground

// TFT screen variables
#define cs   10
#define dc   9
#define rst  8
TFT TFTscreen = TFT(cs, dc, rst);

// Button variables
const int buttonUp = 2;
const int buttonDown = 3;
const int buttonOk = 4;

#define DELAY 1.0/64.0

void setup() {

   Serial.begin(9600); // For Serial Monitor


   pulseSensor.begin(); // Start heartbeat sensor
   TFTscreen.begin(); // Start TFT screen

   drawScreen(); // Draw content of the screen

   // Buttons
   pinMode(buttonUp, INPUT);
   pinMode(buttonDown, INPUT);
   pinMode(buttonOk, INPUT);

bool buttonUpPrev = false;
bool buttonDownPrev = false;
bool buttonOkPrev = false;

void loop(){

   if(buttonUpPrev == HIGH && digitalRead(buttonUp) == LOW){
      Serial.println("button up");

   if(buttonDownPrev == HIGH && digitalRead(buttonDown) == LOW){
      Serial.println("button down");

   if(buttonOkPrev == HIGH && digitalRead(buttonOk) == LOW){
      Serial.println("button ok");

   buttonUpPrev = digitalRead(buttonUp);
   buttonDownPrev = digitalRead(buttonDown);
   buttonOkPrev = digitalRead(buttonOk);



My problem is that when I press one of the buttons, the TFT screen flickers, as if less voltage gets to the screen. Also, sometimes I see "button down" in the Serial Monitor when nothing is being pressed. Overall the device works, but I wonder if I made a mistake.

My question is: Is there a problem with the cabling of this device? I've studied Computer Science and I just know the basics of electronics. Thank you!

  • try using internal pullup resistors ... remove the external pulldown resistors and connect the switches between the data pins and ground
    – jsotola
    Nov 18, 2022 at 15:56
  • Also instead of delay(1.0/64.0);, use delayMicroSeconds(15);.
    – hcheung
    Nov 19, 2022 at 2:42


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.