#include <Wire.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const int buzzerPin = 3;
const int heartRatePotPin = A0;
const int spo2PotPin = A1;
void setup()
{
Serial.begin(9600);
// Initialize DHT sensor
dht.begin();
// Set up buzzer pin
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
// Read values from the heart rate and SpO2 potentiometers
int heartRatePotValue = analogRead(heartRatePotPin);
int spo2PotValue = analogRead(spo2PotPin);
// Map potentiometer values to heart rate and SpO2 ranges
float heartRate = map(heartRatePotValue, 0, 1023, 60, 180); // Maps potentiometer value to heart rate range (60-180 BPM)
float spO2 = map(spo2PotValue, 0, 1023, 90, 100); // Maps potentiometer value to SpO2 range (90-100%)
// Read temperature from DHT sensor
float temperature = dht.readTemperature();
// Check conditions and trigger buzzer if necessary
if (heartRate > 80 || spO2 < 96 || temperature > 37.5)
{
digitalWrite(buzzerPin, HIGH); // Turn the buzzer on
Serial.println("buzzerPin=HIGH");
}
else
{
digitalWrite(buzzerPin, LOW); // Turn the buzzer off
Serial.println("buzzer = low"); }
// Add a delay to avoid rapid updates
delay(1000);
}