// Define the pins for the sensors and the buzzer
const int ldrPin = A0;
const int tempPin = A2;
const int buzzerPin = 1;

// Define the threshold values for the temperature and the light level
const int tempThreshold = 25;
const int lightThreshold = 500;

void setup() {
  // Set the buzzer pin as an output
  pinMode(buzzerPin, OUTPUT);
  // Begin serial communication
  Serial.begin(9600);
}

void loop() {
  // Read the values from the sensors
  int lightLevel = analogRead(ldrPin);
  int tempLevel = analogRead(tempPin);
  // Convert the temperature value to degrees Celsius
  float tempCelsius = (5.0 * tempLevel * 100.0) / 1024.0;
  // Print the values to the serial monitor
  Serial.print("Light level: ");
  Serial.println(lightLevel);
  Serial.print("Temperature: ");
  Serial.print(tempCelsius);
  Serial.println(" C");
  // Check if the temperature is above the threshold and the light level is below the threshold
  if (tempCelsius > tempThreshold && lightLevel < lightThreshold) {
    // Trigger the buzzer
    digitalWrite(buzzerPin, HIGH);
  } else {
    // Turn off the buzzer
    digitalWrite(buzzerPin, LOW);
  }
  // Wait for a short time before reading the sensors again
  delay(200);
}
Loading
ds18b20