int IR=5;                                                //Connect IR out pin to Arduino digital pin 5
int pump=11;                                       // If pump is on then motor is  and viceversa
void setup() {
                                                               // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(IR,INPUT);                    // set IR (5th pin as input pin)
  pinMode(pump,OUTPUT);         // set pump (11th pin as Output pin)
}
void loop() {
                                                           // put your main code here, to run repeatedly:
   digitalWrite(pump,LOW);       // now pump is on condition (and motor is off condition)   
  if (IR < 500)                                // when bottle sense by IR the value reduced lesser than 500 
  {
    delay(70);                                         // after 0.07 seconds
    digitalWrite(pump,HIGH);         // pump turn on (and motor turn off)
    delay(7000);                                  // now 7 seconds bottle will fill (you can change delay )
     digitalWrite(pump,LOW);        // Now pump turns off (and motor turns on)
    delay(3000);                                // let 3 seconsd to pass the bottle from the IR sensing point
  }
  else
  {
    digitalWrite(pump,LOW);  // if bottle is not sensed the motor is continues to run and pump is off
  }                                                  // these process continues 
}

Comments

Popular posts from this blog