const float BETA = 3950;
const int yellowLedPin = 9; // Pin untuk LED kuning
const int redLedPin = 10; // Pin untuk LED merah
void setup() {
Serial.begin(9600);
pinMode(yellowLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
void loop() {
int analogValue = analogRead(A1);
float celcius = 1 / (log(1/(1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celcius);
Serial.print(" Celcius");
float fahrenheit = (9.0/5.0 * celcius) + 32;
Serial.print(" ");
Serial.print(fahrenheit);
Serial.println(" Fahrenheit");
// Mengatur LED berdasarkan suhu
if (celcius > 38.00) {
digitalWrite(redLedPin, HIGH);
digitalWrite(yellowLedPin, LOW);
} else if (celcius > 30.00) {
digitalWrite(yellowLedPin, HIGH);
digitalWrite(redLedPin, LOW);
} else {
digitalWrite(yellowLedPin, LOW);
digitalWrite(redLedPin, LOW);
}
delay(1000);
}