Sensor de chuva

Good Afternoon Everyone, I need a code to Arduino Uno to a rain sensor, that when it rains the motor rotates one way and when it stops raining (dry sensor) the motor spin the other way automatico.To urgent need for my CBT.

following code to using that.
(remember: I want to use the digital port of the Arduino.)
(I'm also using a bridge L298N H)

int input1 = 4;
int enable1 = 2;
int input2 = 5;
int button1 = 6;
int button2 = 7;
int sensorChuva = 9;
int infra = 12;
 
void setup(){
  pinMode(input1, OUTPUT);
  pinMode(enable1, OUTPUT);
  pinMode(input2, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(sensorChuva, INPUT);
  pinMode(infra,INPUT);
}
 
void rotateLeft(){
  digitalWrite(enable1, HIGH);
  digitalWrite(input2, LOW);
  digitalWrite(input1, HIGH);
}
 
void rotateRight(){
  digitalWrite(enable1, HIGH);
  digitalWrite(input1, LOW);
  digitalWrite(input2, HIGH);
}
 
void parar(){
  digitalWrite(enable1, LOW);
  digitalWrite(input1, LOW);
  digitalWrite(input2, LOW);
}
 
void loop(){
  while(digitalRead(button1) == HIGH)
   {
    rotateLeft();
    delay(2000);
  }
 
  while(digitalRead(button2) == HIGH)
  {
      rotateRight();
     
  }
 
 
  parar();
}

obrigado a todos

moderator update: added code tags = # button above smileys -- etiquetas de código adicionado = # botão acima smileys (google)

please also ask your question also in English on the international part of the forum.
por favor, faça sua pergunta também em Inglês na parte internacional do fórum.

Google translate
Good Afternoon Everyone, I need a code to Arduino Uno to a rain sensor, that when it rains the motor rotates one way and when it stops raining (dry sensor) the motor spin the other way automatico.To urgent need for my CBT.
following code to using that.
(remember: I want to use the digital port of the Arduino.)
(I'm also using a bridge L298N H)