Automatic Water Tank Filling System Using Arduino | Arduino Project

by | May 17, 2022 | Arduino, Coding

Introduction

We all must have faced the issue of not having sufficient water in our tanks when required or water flowing off from our tanks as we forget to switch off the motor on time. So to solve this problem, we can use Arduino to set conditions to automatically run the motor to fill our water tanks. In this coding project tutorial, we will make an Automatic Water Tank Filling System using Arduino. For this project, we will use a DC motor and ultrasonic distance sensor to automatically fill the tank when its level reaches a certain height.

 

Supplies

In order to make an Automatic Water Tank Filling System using Arduino, we will require the following components:

Components

Circuit Diagram

Automatic Water Tank Filling System Using Arduino | Arduino Project

Steps To Make An Automatic Water Tank Filling System Using Arduino

Step 1: Gather all the components on the Digital Board or Physical Table.

Ultrasonic Distance Sensor:

Step 2: Connect the Power terminal of the Ultrasonic Distance Sensor to the 5V pin of the Arduino at its Analog Side.

Step 3: Connect the Trigger Terminal of it to the 10 number pin of the Arduino.

Step 4: Connect the Echo Terminal of it to the 11 number pin of the Arduino.

Step 5: Connect the Ground Terminal of it to the GND pin of the Arduino.

DC Motor:

Step 6: Connect the one terminal of it to the 5V pin of the Arduino.

Step 7: Connect the second terminal of it to the 9 number pin of the Arduino and the GND pin of the Arduino.

Source Code

int distance = 0;

long readUltrasonicDistance(int triggerPin, int echoPin)

{

pinMode(triggerPin, OUTPUT);

digitalWrite(triggerPin, LOW);

delayMicroseconds(2);




digitalWrite(triggerPin, HIGH);

delayMicroseconds(10);

digitalWrite(triggerPin, LOW);

pinMode(echoPin, INPUT);




return pulseIn(echoPin, HIGH);

}

void setup()

{

pinMode(9, OUTPUT);

}

void loop()

{

distance = 0.01723 * readUltrasonicDistance(10, 11);

digitalWrite(9, LOW);

if(distance > 150)

{

digitalWrite(9, HIGH);

delay(5000);

if(distance < 30)

{

digitalWrite(9, LOW);

}

}

}

Explanation of the Code

1. In the beginning, we initialised an integer variable to 0.

2. Then, we have used a function to read ultrasonic distance using two parameters, which are inputs for the sensor. In the setup function, we have configured pin number 9 for output purposes.

3. In the loop function, we are calculating the distance of the water from the top of the tank in centimetres and storing that value in a variable.

4. After this, we use the if statement, in which, if the distance is less than 150 cm from the top of the tank, we are giving high power to the DC motor. Hence, it will rotate till some set time(in this case, 5 seconds), and meanwhile, if the distance is less than 30 cm, it will turn off.

In this way, our tank will be filled automatically.

Output

We will get the following output on the successful completion of the project. On starting the simulation, the DC motor will rotate till the tank is filled up to a certain level.

Automatic Water Tank Filling System Using Arduino

 

 

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published.