Hi everyone, I am new to Arduino and I am trying to build an Automatic Water Pump Controller. Can anyone help me to complete my project?
https://www.tinkercad.com/things/6i1RQUcbeF5-automatic-water-pump-controller
I have made it with Tinkercad.
Here is my Code.
#include <LiquidCrystal.h>
int ledPin = 6; // LED is connected to digital pin 6
int flow=A0; // Water flow sensor is connected to A0 Analog Pin
int qut=A1;
int hlf=A2;
int thf=A3;
int ful=A4;
int motor=8;
int buz=7;
int s; //Flow status flag
int q; // quater
int h; // half
int t; //75 %
int f; //full
int i; //motor status flag
int v=100; //comparison variable(needs some adjustment)
int b=0; //buzzer flag
int m=0; //motor flag
int c=0; //flow flag
int sumValue; // a variable to keep track of when sum tank is empty or not.
int counter = 0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte Level0[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111
};
byte Level1[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111
};
byte Level2[8] = {
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte Level3[8] = {
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte NoLevel[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111
};
byte tank[8] = {
0b10001,
0b10001,
0b10001,
0b10001,
0b10001,
0b11111,
0b11111,
0b11111
};
byte arrow[8] = {
0b00000,
0b00100,
0b00110,
0b11111,
0b11111,
0b00110,
0b00100,
0b00000
};
void setup()
{
Serial.begin(9600);
lcd.createChar(0, Level0);
lcd.createChar(1, Level1);
lcd.createChar(2, Level2);
lcd.createChar(3, Level3);
lcd.createChar(4, NoLevel);
lcd.createChar(5, tank);
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
pinMode(qut,INPUT);
pinMode(hlf,INPUT);
pinMode(qut,INPUT);
pinMode(ful,INPUT);
pinMode(flow,INPUT);
pinMode(motor,OUTPUT);
pinMode(buz,OUTPUT);
lcd.begin(16, 2);
digitalWrite(ledPin, HIGH); // turn the LED on
digitalWrite(buz, HIGH);
delay(250);
digitalWrite(buz,LOW);
digitalWrite(ledPin, LOW); // turn the LED OFF
lcd.print("AUTOMATIC WATER");
lcd.setCursor(0,1);
lcd.print("PUMP COMTROLLER");
delay(5000);
lcd.clear();
lcd.setCursor(7,0);
lcd.print("BY");
lcd.setCursor(2,1);
lcd.print("BIMAN MANDAL");
delay(5000);
}
void loop()
{
i=digitalRead(motor);
s=analogRead(flow);
q=analogRead(qut);
h=analogRead(hlf);
t=analogRead(thf);
f=analogRead(ful);
lcd.clear();
if(f>v && t>v && h>v && q>v )
{
lcd.setCursor(0,0);
lcd.write(byte(4));
lcd.write(byte(0));
lcd.write(byte(1));
lcd.write(byte(2));
lcd.write(byte(3));
lcd.setCursor(6,0);
lcd.print("TANK FULL");
m=0;
b=0;
}
else
{
if(f<v && t>v && h>v && q>v)
{
lcd.setCursor(0,0);
lcd.write(byte(4));
lcd.write(byte(0));
lcd.write(byte(1));
lcd.write(byte(2));
lcd.setCursor(5,0);
lcd.print("75%");
b=0;
}
else
{
if(f<v && t<v && h>v && q>v)
{
lcd.setCursor(0,0);
lcd.write(byte(4));
lcd.write(byte(0));
lcd.write(byte(1));
lcd.setCursor(5,0);
lcd.print("HALF");
b=0;
}
else
if(f<v && t<v && h<v && q>v)
{
lcd.setCursor(0,0);
lcd.write(byte(4));
lcd.write(byte(0));
lcd.setCursor(5,0);
lcd.print("25%");
b=0;
}
else
{
if(f<v && t<v && h<v && q<v)
{
lcd.setCursor(0,0);
lcd.write(byte(5));
lcd.print("TANK EMPTY");
m=1;
b=0;
}
else
{
digitalWrite(motor,LOW);
lcd.setCursor(0,0);
lcd.print("ERROR!");
b=1;
}
}}}
if(i==HIGH)
{
lcd.setCursor(0,1);
lcd.print("MOTOR ON");
digitalWrite(ledPin, HIGH); // turn the LED on
}
else
{
lcd.setCursor(0,1);
lcd.print("MOTOR OFF");
digitalWrite(ledPin, LOW); // turn the LED OFF
}
if(s>v && m==1)
{
digitalWrite(motor,HIGH);
digitalWrite(ledPin, HIGH); // turn the LED on
}
if(s<v && m==1)
{
delay(1000);
lcd.setCursor(13,0);
lcd.print("NO");
lcd.setCursor(12,1);
lcd.print("FLOW");
delay(500);
digitalWrite(motor,LOW);
digitalWrite(ledPin, LOW); // turn the LED OFF
c=1;
}
if (sumValue == HIGH)
{
counter = 0;
c=0;
}
if(s>v)
{
c=0;
}
if(m==0)
{
digitalWrite(motor,LOW);
digitalWrite(ledPin, LOW); // turn the LED OFF
}
if(b==1 || c==1)
{
digitalWrite(buz,HIGH);
digitalWrite(ledPin, HIGH); // turn the LED on
delay(500);
digitalWrite(buz,LOW);
digitalWrite(ledPin, LOW); // turn the LED OFF
delay(500);
}
else
{
digitalWrite(buz,LOW);
digitalWrite(ledPin, LOW); // turn the LED OFF
delay(2000);
}
}
it is working fine. But now I want to add some extra features to it.
- Emergency on and off with a Button or two different buttons.
- If there is no water flowing in the tank, the Motor will on and off 3 times with a 30-second gap and then finally stop. A reset button will be there to start over.
- Overvoltage and undervoltage protection with ZMPT101B.
If anyone has any ideas please help me. I will be very grateful.
Thanks in advance.



