Automatic Water Tap Control System Using Arduino
Let's see how it is made.
Components list:
* Arduino Nano
* 16*2 LCD display
* Water Tap
* IR Sensor
* 10k potentiometer
* PIR Motion Sensor
* 5v LED light
* 12v Dc water pump
* 12v transformer
* BC547 Transistor
* 4*2 Battery
* On/OFF Switch
* 10k Resistor
* 100ohm resistor
* Veroboard
* Some Jumper wire
For making this project single Arduino nano-board, 16*2 LCD Display. This is a PIR motion sensor and 5v LED light.The power switch for the circuit. This is another PIR motion sensor and 5v LED light. Here we supply the power using two 4V batteries. This is the rectifier circuit with 12V Auto Dc Transformer. Here we connect the 12V dc water pump motor. This IR obstacle sensor and water Tap.
Description:
This is our complete project view. This is our circuit diagram for the project.The the source code for the project is provided below. In the beginning of the code we include the LCD library. After that we define motion sensor pins, LED light pins, motor connected pin and IR sensor pin. Here we declare three variables. In the void setup section we initialize serial motion and LCD. Then we set motion pins for INPUT and LED light pin for OUTPUT. In the loop section we call two functions,one for motion control and another one is Motor control. Inside the motor control function we read the Ir sensor value. When the IR sensor value is less than 900 the motor will turn ON. And when the Ir sensor value is greater than 900 the motor will turn OFF. This is the motion control function.Here we read two motion control values. When motion sensor1 value will be equal to 1 then LED light1 will be turned ON else it will be OFF. When the motion sensor2 value will be equal to 1 LED light2 will be turned ON otherwise it will be OFF. The Source code will be given below description. You can easily download the source code from the link. After uploading the code let’s see how the project working. First we put some water into the cup. Next when I put my hand under the water tap,Ir sensor detected my hand and the water pump motor turn ON. we can see that water comes through the water tap and LCD display shows Motor is ON. Project is working Nicely. Next we will check another part of the project. When I put my hand inside the room light is turn ON and the LCD display shows the result.
Code:
int relay = 13; // relay is connected with pin 13
// this relay will be used to control the solenoid valve
int sensor = 4; // Infrared sensor is connected with pin4
int flag = 0; // this is a flag and it is changed from 0 to 1 and from 1 to 0 each time sensor is activated
int sflag = 0; // sensor flag which is used to monitor the state of the sensor when there is nothing infront of it.
void setup()
{
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
pinMode(sensor, INPUT);
digitalWrite(sensor, HIGH);
}
void loop()
{
if( (digitalRead(sensor) == LOW) && (flag == 0) && (sflag == 0) )
{
flag = 1;
digitalWrite(relay, HIGH);
sflag = 1;
}
if( (digitalRead(sensor) == LOW) && (flag == 1) && (sflag == 0) )
{
flag = 0;
digitalWrite(relay, LOW);
sflag = 1;
}
if( (digitalRead(sensor) == HIGH)) // if there is nothing in front of the sensor
{
sflag = 0;
delay(100);
}
}
I hope you enjoyed working on this project and completed it successfully.And if you find this blog interesting please do share it with your friends.
I really appreciate your blog
ReplyDeleteNice
ReplyDelete