Project showcase
AHWS

AHWS © GPL3+

See this post on Patreon. https://www.patreon.com/Ardumaniac

  • 11 views
  • 0 comments
  • 0 respects

Components and supplies

Apps and online services

About this project

Code

AHWSArduino
/*
 * AHWS(Automated Home Water System)
 * made by Nurlan Aliyev in Lerik,Azerbaijan
 * The variable names are in Azeri I'll try to translate them in this comment;
 * gerkon = reedSwitch
 * qirmiziLed = redLed
 * sariLed = yellowLed
 * yasilLed = greenLed
 * goyLed = blueLed
 * aqLed = whiteLed
 * masafa = range
 * Hsu = hWater
 * miqdar = waterVolume
 * tempratur = temp
 * tazyiq = pressure
 * masafa1 = range 1
*/
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS A0
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // bl - backlight, blpol - полярность подсветки

int buttonKlapan = 2;
int gerkon = 3;
int qirmiziLed = 9;
int elPin = 7;
int avtoPin = 6;
int sariLed = 10;
int yasilLed = 11;
int trigPin = 5;    //Trigger
int echoPin = 4;    //Exo
int buzzPin = 8; // Ses ucun (buzzer)
int goyLed = 12;
int aqLed = 13;
int flag = 0; // movcud vəziyyet
int regim = 0; // deyismek
int klcdPin = A2; // Lcd de gostermək
int tezPin = A1; // Lcd de gostermək
int tRead = 0; // Lcd de gostermək
int tok = 0; // klapan qosulubsa
float duration,masafa,Hsu,miqdar,tempratur,tazyiq,masafa1;
void setup() {
 lcd.begin(20,4);   
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(gerkon, INPUT);
 pinMode(qirmiziLed, OUTPUT);
 pinMode(sariLed, OUTPUT);
 pinMode(yasilLed, OUTPUT);
 pinMode(goyLed, OUTPUT);
 pinMode(aqLed, OUTPUT);
 pinMode(buzzPin, OUTPUT);
  pinMode(avtoPin, OUTPUT);
  pinMode(elPin, OUTPUT);
 sensors.begin();
}
void loop() {
  sensors.requestTemperatures();
  tempratur = sensors.getTempCByIndex(0); 
digitalWrite(trigPin, LOW);
delayMicroseconds(2.5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(5);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
masafa = duration/2*0.0365;
masafa1 = masafa / 100;
Hsu = 233 - masafa;
miqdar = Hsu/100*3.7234*1000;
tRead = analogRead(tezPin);
tazyiq =tRead*1.111/1024-0.555;
lcd.setCursor(3,0);
lcd.print("SU    ");
lcd.print((int)miqdar);
lcd.print(" litr    ");
lcd.setCursor(3,1);
lcd.print("HAVA  ");
lcd.print((int)tempratur);
lcd.print(" C    ");
lcd.setCursor(3,2);
lcd.print("P     ");
lcd.print(tazyiq);
lcd.print(" Bar");
delay(1000); 
pinMode(klcdPin, INPUT);
tok = analogRead(klcdPin);
if(tok == 0 )
{
 lcd.setCursor(6,3);
lcd.print("SU BAGLI");
delayMicroseconds(10);
}
else if(tok > 0 )
{
 lcd.setCursor(6,3);
lcd.print("SU ACIQ ");
delayMicroseconds(10);
}
if(Hsu <= 20)
{
  digitalWrite(qirmiziLed, HIGH);
  digitalWrite(sariLed, LOW);
  digitalWrite(yasilLed, LOW);
  digitalWrite(goyLed, LOW);
  digitalWrite(aqLed, LOW);
  digitalWrite(avtoPin, HIGH);
}
else if(Hsu > 20 && Hsu <= 50)
{
  digitalWrite(qirmiziLed, LOW);
  digitalWrite(sariLed, HIGH);
  digitalWrite(yasilLed, LOW);
  digitalWrite(goyLed, LOW);
  digitalWrite(aqLed, LOW);
  digitalWrite(avtoPin, HIGH);
}
else if(Hsu > 50 && Hsu <=150)
{
  digitalWrite(qirmiziLed, LOW);
  digitalWrite(sariLed, LOW);
  digitalWrite(yasilLed, HIGH);
  digitalWrite(goyLed, LOW);
  digitalWrite(aqLed, LOW);
  digitalWrite(avtoPin, HIGH);
}
else if(Hsu > 150 && Hsu < 203)
{
  digitalWrite(qirmiziLed, LOW);
  digitalWrite(sariLed, LOW);
  digitalWrite(yasilLed, LOW);
  digitalWrite(goyLed, HIGH);
  digitalWrite(aqLed, LOW);
}
else if(Hsu >= 203)
{
  digitalWrite(qirmiziLed, LOW);
  digitalWrite(sariLed, LOW);
  digitalWrite(yasilLed, LOW);
  digitalWrite(goyLed, LOW);
  digitalWrite(aqLed, HIGH); 
}
if(digitalRead(gerkon) == LOW)
{
  digitalWrite(buzzPin, LOW);
}
else if(digitalRead(gerkon) == HIGH)
{
  digitalWrite(avtoPin, LOW);
  digitalWrite(buzzPin, HIGH);
    analogWrite(buzzPin, 255); // включаем пьезоизлучатель
    delay(1000);  // на 1000 мс (1 сек),
    analogWrite(buzzPin, 0); // выключаем звук
    delay(1000); // на 1 сек.
}

if(digitalRead(buttonKlapan) == HIGH && flag == 0)
{
  regim ++;
  flag = 1;
  if(regim > 1)
  {
    regim = 0;
  }
}
if(digitalRead(buttonKlapan) == LOW && flag == 1)
{
  flag = 0;
}
if(regim == 0)
{
  digitalWrite(elPin, HIGH); 
}
if(regim == 1)
{
  digitalWrite(elPin, LOW); 
}
}

Comments

Add projectSign up / Login