Arduino Water Level Indicator Using LCD | Arduino Project

by | May 20, 2022 | Arduino, Coding

Introduction

In today’s coding tutorial, we are going to make an Arduino Water Level Indicator using LCD. To make this Arduino project, we will use an LCD to indicate the empty tank in centimeters.

Water Level indicators are very useful in home apartments, complexes, factories, and other places with overhead tanks. With the use of the water level indicator, we can determine the level at which water is in any type of container. This is beneficial to save water by stopping overflow and also can be used to trigger an alarm when the water level is too low, and the tank needs to be refilled. So now, let us see how this works.

 

Supplies

In order to make an Arduino Water Level Indicator using LCD, we will require the following components:

Components

Circuit Diagram

Arduino Water Level Indicator Using LCD | Arduino Project

Steps To Make An Arduino Water Level Indicator Using LCD

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.

LCD:

Step 6: Connect the Power & the LED anode terminal of it to the 5V pin of the Arduino.

Step 7: Connect the Ground, Contrast, Read/Write & LED cathode terminals of it to the GND pin of the Arduino, as shown in the circuit.

Step 8: Connect the Register Select, Enable, & DB4 to DB7 pins of it to the 2 to 7 number pins of the Arduino, as shown in the figure.

Source Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

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()

{

lcd.begin(16,2);

}

void loop()

{

distance = 0.01723 * readUltrasonicDistance(10, 11);

lcd.setCursor(0,0);

lcd.println("Empty in cm = ");

lcd.setCursor(8,1);

lcd.print(distance);

delay(5000);

}

Explanation of the Code

1. In the beginning, we included a liquid crystal library. After that, we declared an object and initialized it with the pin number to which the LCD is connected to the Arduino. We have also initialized one integer variable to 0.

2. Now, we are using a function that takes two values from the sensor and produces the Ultrasonic distance.

3. In the setup function, we are setting up the LCD’s number of columns and rows, respectively.

4. In the loop function, we are calculating the distance of water from the top in centimeters. Once the distance is calculated, we set the cursor of the LCD and print the distance in it.

5. We have also used a delay function that takes time in milliseconds.

Output

We will get the following output on the successful completion of the project.

Arduino Water Level Indicator Using LCD - Arduino Project

The LCD screen will show how much the tank is empty in centimeters upon starting the simulation.

 

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published.