#include <LiquidCrystal_I2C.h>
#define Pulse_sensor 14
#define Temp_sensor 27
#define LED 2
#define buzzer 4
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
ledcSetup(0, 1000, 10); // Use LEDC channel 0, 1000 Hz, 10-bit depth
ledcAttachPin(buzzer, 0); // Attach buzzer to LEDC channel 0
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();
pinMode(LED, OUTPUT);
pinMode(buzzer ,OUTPUT );
digitalWrite(buzzer, LOW);
digitalWrite(LED, LOW);
}
void check(int pulse,int temp)
{
if(pulse >=1000)
{
digitalWrite(LED, HIGH);
tone(buzzer,1030);
}
else if(temp>=1000)
{
digitalWrite(LED, HIGH);
tone(buzzer,1030);
}
else
{
digitalWrite(LED,LOW);
noTone(buzzer);
}
}
// void checktemp(int temp)
// {
// }
void loop() {
// put your main code here, to run repeatedly:
int pulse = analogRead(14);
int temp= analogRead(27);
//digitalWrite(LED, HIGH);
//tone(buzzer,1030);
// set cursor to first column, first row
lcd.setCursor(0, 0);
Serial.print("Pulse value: ");
Serial.println(pulse);
lcd.print("Pulse:");
lcd.print(pulse);
lcd.setCursor(0,1);
Serial.print("Temperatue : ");
Serial.println(temp);
lcd.print("Temperature:");
lcd.print(temp);
check(pulse,temp);
delay(1000);
delay(10); // this speeds up the simulation
lcd.clear();
}