#include <Arduino.h>

// Pins for components
const int buttonPin = 27;    // Power button
const int ldrPin = 15;      // LDR sensor (change as needed)
const int lm35Pin = 14;     // LM35 sensor (change as needed)
const int greenLedPin = 13;
const int redLedPin = 12;
const int buzzerPin = 16;   // Change as needed
const int motor1Pin = 4;    // Motor 1
const int motor2Pin = 5;    // Motor 2

void setup() {
  Serial.begin(115200);

  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(greenLedPin, OUTPUT);
  pinMode(redLedPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(motor1Pin, OUTPUT);
  pinMode(motor2Pin, OUTPUT);
}

void loop() {
  // Check power button state
  if (digitalRead(buttonPin) == LOW) {
    // Power button pressed, add your laundry system logic here
    checkWeatherAndTemperature();
    delay(1000); // Debounce delay
  }
}

void checkWeatherAndTemperature() {
  // Read LDR sensor value
  int ldrValue = analogRead(ldrPin);

  // Read LM35 sensor value
  int lm35Value = analogRead(lm35Pin);
  float temperature = (lm35Value * 500.0) / 1023.0;

  // Add your logic based on sensor values
  if (ldrValue > 400 && temperature > 28.0) {
    // Sunny and temperature > 28°C
    digitalWrite(greenLedPin, HIGH);
    digitalWrite(motor1Pin, HIGH);
    Serial.println("Hang The Clothes!");

    // Add delay for 10 seconds
    delay(1000);

    // Turn off components
    digitalWrite(greenLedPin, LOW);
    digitalWrite(motor1Pin, LOW);
  } else if (ldrValue < 300 && temperature < 20.0) {
    // Cloudy and temperature < 20°C
    digitalWrite(redLedPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    digitalWrite(motor2Pin, HIGH);
    Serial.println("Take the sheet inside!");

    // Add delay for 10 seconds
    delay(1000);

    // Turn off components
    digitalWrite(redLedPin, LOW);
    digitalWrite(buzzerPin, LOW);
    digitalWrite(motor2Pin, LOW);
  }
}