Water Level Indicator Using Arduino Tinker Cad

by Simarsodhi18 in Circuits > Arduino

1140 Views, 1 Favorites, 0 Comments

Water Level Indicator Using Arduino Tinker Cad

Screen Shot 2022-06-15 at 12.20.47 AM.png

This instructable is about a fully functional water level controller using Arduino. The circuit displays the level of water in the tank and switches the motor ON when the water level goes below a predetermined level. The circuit automatically switches the motor OFF when the tank is full. A beep sound is generated when the level in the tank is full.

Step 1 - Components You Need

Screen Shot 2022-06-15 at 12.24.39 AM.png
Screen Shot 2022-06-15 at 12.25.01 AM.png

You will need the following materials for making your own Water Level Indicator:

1. Arduino UNO or nano

2. Breadboard

3. LED's

4. Motor pump

5. Jumper wires

6. Buzzer

7. Resistor (220 ohms)

Step 2 - Circuit Diagram

Screen Shot 2022-06-15 at 12.27.30 AM.png

I have used 4 LEDs for 4 different levels.

1. Green led is connected with pin 2 indicating the level 1 and pump will start automatically at level 1
2. Orange led is connected with pin 3 indicating the level 2

3. Yellow led is connected with pin 4 indicating the level 3

4. Red led is connected with pin 5 indicating the level 4 and buzzer is also connected along with level 4 which means the tank is full.

At level 4 all the 4 less will glow , the buzzer will also beep and the pump will stop automatically

Step 3 - Code

int distanceTreshold = 0;

int cm = 0;

int buttonstate = 0;

long readUltrasonicDistance(int triggerPin, int echoPin)

{

pinMode(triggerPin, OUTPUT); // Clear the trigger digitalWrite(triggerPin, LOW); delayMicroseconds(2); // Sets the trigger pin to HIGH state for 10 microseconds digitalWrite(triggerPin, HIGH); delayMicroseconds(10); digitalWrite(triggerPin, LOW); pinMode(echoPin, INPUT); // Reads the echo pin, and returns the sound wave travel time in microseconds return pulseIn(echoPin, HIGH);

}

void setup()

{ pinMode(9, INPUT); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(8, OUTPUT); pinMode(6, OUTPUT);

}

void loop() { buttonstate = digitalRead(9); distanceTreshold = 300; cm = 0.01723 * readUltrasonicDistance(7, 7); if (buttonstate == HIGH){ if (cm > distanceTreshold) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, HIGH); noTone(6);

}

if (cm <= distanceTreshold && cm > distanceTreshold - 75) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, HIGH); noTone(6); delay(1000); // Wait for 1000 millisecond(s) digitalWrite(2, HIGH); } if (cm <= distanceTreshold - 75 && cm > distanceTreshold - 150) { digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, HIGH); noTone(6); delay(1000); // Wait for 1000 millisecond(s) digitalWrite(3, HIGH); } if (cm <= distanceTreshold - 150 && cm > distanceTreshold - 225) { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, HIGH); noTone(6); delay(1000); // Wait for 1000 millisecond(s) digitalWrite(4, HIGH); } if (cm <= distanceTreshold - 225 && cm > distanceTreshold - 285) { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(8, HIGH); delay(1000); // Wait for 1000 millisecond(s) digitalWrite(5, HIGH); } if (cm <= distanceTreshold - 285) { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(8, LOW); tone(6, 523, 1000); // play tone 60 (C5 = 523 Hz) } } if (buttonstate == LOW){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, LOW); noTone(6); } }