#include <Wire.h>
#include <Adafruit_SSD1306.h>
// OLED Display Configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Sensor Pin Definitions
#define HEART_SENSOR 36 // GPIO 36 (VN) for analog input
#define TEMP_SENSOR 39 // GPIO 39 (VP) for analog input
#define ALERT_LED 13 // Alert LED for abnormal readings
void setup() {
Serial.begin(115200);
// Initialize OLED Display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("SSD1306 OLED Display Failed!");
while (1);
}
display.clearDisplay();
pinMode(ALERT_LED, OUTPUT);
}
void loop() {
// Simulate Heart Rate & Temperature
int heartRate = analogRead(HEART_SENSOR) / 10; // Scale 0-100
int temperature = map(analogRead(TEMP_SENSOR), 0, 4095, 30, 40); // Simulated Temp in °C
// Display on OLED
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(10, 10);
display.print("HR: "); display.print(heartRate); display.println(" BPM");
display.print("Temp: "); display.print(temperature); display.println(" C");
display.display();
// Check for abnormal conditions
if (heartRate < 50 || heartRate > 120 || temperature > 38) {
digitalWrite(ALERT_LED, HIGH); // Turn on Alert LED
} else {
digitalWrite(ALERT_LED, LOW);
}
Serial.print("Heart Rate: "); Serial.print(heartRate); Serial.println(" BPM");
Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" C");
Serial.println("---------------------");
delay(1000);
}