#include <Servo.h>

Servo myServo;

const int rainSensorPin = 2;  // Pin connected to the digital output of the rain sensor
const int servoPin = 9;       // Pin connected to the signal pin of the servo
const int threshold = 500;    // Threshold for rain detection

void setup() {
  pinMode(rainSensorPin, INPUT);
  myServo.attach(servoPin);
  myServo.write(0);  // Initial position of the servo
  Serial.begin(9600);
}

void loop() {
  int sensorValue = digitalRead(rainSensorPin);
  Serial.println(sensorValue);
  
  if (sensorValue == LOW) {
    // Rain detected
    myServo.write(90);  // Move the servo to 90 degrees
  } else {
    // No rain
    myServo.write(0);   // Move the servo back to 0 degrees
  }

  delay(1000);  // Delay to avoid rapid servo movements
}