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 seconsd
digitalWrite(pump,high); // pump turn on (and motor turn off)
delay(7000); // now 7 seconsd bottle will fill (you can change delay as you required)
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 contineous to run and pump is off
} // these process constinue
}
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 seconsd
digitalWrite(pump,high); // pump turn on (and motor turn off)
delay(7000); // now 7 seconsd bottle will fill (you can change delay as you required)
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 contineous to run and pump is off
} // these process constinue
}