const int lm35Pin = A5; // LM35 analog input pin
const int redLedPin = 3; // Red LED pin
const int otherLedPin = 1; // Other LED pin
const int thresholdTemp = 500; // Threshold temperature in Celsius
void setup() {
pinMode(redLedPin, OUTPUT);
pinMode(otherLedPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(lm35Pin);
float temperature = (sensorValue * 5.0 / 1024.0) * 100.0;
Serial.print("Temperature: ");
Serial.println(temperature);
if (temperature > thresholdTemp) {
digitalWrite(redLedPin, HIGH);
digitalWrite(otherLedPin, LOW);
} else {
digitalWrite(redLedPin, LOW);
digitalWrite(otherLedPin, HIGH);
}
delay(1000); // Delay for reading every 1 second
}
Loading
ds18b20
ds18b20