#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1 // Reset pin not used
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int potpin = 34;
int heartValue = 0;
void setup() {
Serial.begin(115200);
// Initialize with the I2C address of your OLED display (0x3C)
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C, OLED_RESET)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
// Clear the display
display.clearDisplay();
display.display();
}
void loop() {
heartValue = analogRead(potpin);
Serial.println(heartValue);
// Clear the previous content on the display
display.clearDisplay();
// Set text size and color
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
// Display the heart value on the OLED
display.setCursor(0,0);
display.print("Heart Value: ");
display.print(heartValue);
// Update the display
display.display();
delay(10); // You can adjust the delay to control the refresh rate
}