Wednesday, May 6, 2015

Automatic Water level controller with Level display on LCD





previously I made an automatic water level controller , you can check this link here, Please check the link which I have given to know more about the detail of this project. This is an upgrade version to the previous one, I've added an LCD display to the project to display the water level.

Arduino Code:

/*
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v 
 GND to arduino GND
 Echo to Arduino pin 9 
 Trig to Arduino pin 8*/
 /* LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)*/

#include<LiquidCrystal.h> // include the library code for lcd
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //  
#define echopin  9 // echo pin
#define trigpin 8 // Trigger pin

int maximumRange = 50;
long duration, distance;

void setup() {
  lcd.begin(16,2);
  Serial.begin (9600);
  pinMode (trigpin, OUTPUT);
  pinMode (echopin, INPUT );
  pinMode (4, OUTPUT);
  pinMode (13,OUTPUT);
}
  
void loop ()
{
  {
    digitalWrite(trigpin,LOW);
    delayMicroseconds(2);
    
    digitalWrite(trigpin,HIGH);
    delayMicroseconds(10);
    
    duration=pulseIn (echopin,HIGH);
    
    distance= duration/58.2;
    delay (50);
    Serial.println(distance);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("water level :");
    lcd.print(distance);
    delay(100);
    
  }
  
 if (distance >= 25 ){
   digitalWrite (7,HIGH);// connect to relay(motor)
   digitalWrite (13,HIGH);
   lcd.setCursor(0,1);
   lcd.print("Motor Started");
   delay(100);
 }

 else if (distance <=5) {
   digitalWrite (7,LOW); // connect to relay(motor)
   digitalWrite (13,LOW);
   lcd.setCursor(0,1);
   lcd.print("Tank is full");
   delay(100);
   
 }

}

----------------------------------------------------------------------------------------------------------------------------

Arduino file can be downloaded from this link here

8 comments :

Post a Comment