int temperaturePin = A0; // Analog pin for the temperature sensor
int buzzerPin = 9; // Digital pin for the buzzer
int ledPin = 10; // Digital pin for the LED
void setup() {
Serial.begin(9600);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(A0,INPUT);
}
void loop() {
// Convert analog value to Celsius
float celcius = 1/ (log(1 / (1023. /analogRead(A0) - 1)) / 3950 + 1.0 / 298.15) -273.15;
// Print temperature to the serial monitor
Serial.print("Temperature: ");
Serial.print(celcius);
Serial.println(" °C");
// if temperature grater 38°C
if (celcius > 38) {
// Activate the buzzer
tone(9, 2000); // Play a 2000Hz tone
} else {
// Deactivate the buzzer
noTone(9);
}
// Map the temperature to LED brightness (0-255)
int brightness = map(analogRead(A0), 953, 115, 0, 255);
analogWrite(10, brightness);
delay(1000);
}