source code for sensor and dc motor

material used
Arduino uno
dc motor
rain sensor

help: source code to run dc motor for 2 secs when the raindrop falls on the rainwater sensor.

Did you look at examples in the IDE and on the web? Something that you don't understand?

In general you can not connect a dc motor to an Arduino. Very small motors might be possible if you take precautions with a fly back diode.

It is unlikely anyone is going to give , or design for you , the code - although you could pay someone for it .
Look at and learn from the IDE examples , see how you can adapt them to read your rain sensor or switch a motor on and off . Google “using a transistor as a switch” .

What will you learn if someone just gives you the code ?

pranithsundar:
help: source code to run dc motor for 2 secs when the raindrop falls on the rainwater sensor.

That's easy!

// run dc motor for 2 secs when the raindrop falls on the rainwater sensor.
const byte RainSensorPin = A0;
const int RainSensorThreshold = 1000;
const byte MotorControlPin = 3;


void setup()
{
  digitalWrite(MotorControlPin, LOW);
  pinMode(MotorControlPin, OUTPUT);
}


void loop()
{
  if (analogRead(RainSensorPin) < RainSensorThreshold)
  {
    digitalWrite(MotorControlPin, HIGH);
    delay(2000);
    digitalWrite(MotorControlPin, LOW);
  }
}

Now you just have to figure out what hardware to use and how to connect the Arduino pins to your hardware.