-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMart_Shower_COde.ino
69 lines (66 loc) · 1.39 KB
/
SMart_Shower_COde.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int X;
int Y;
float TIME = 0.0 ;
float FREQUENCY = 0.0;
float WATER = 0.0;
float TOTAL = 0.0;
float LS = 0.0;
const int input = A0;
void setup()
{
pinMode(13,OUTPUT);
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Smart Shower");
lcd.setCursor(0, 1);
lcd.print(" Team CRONOZ");
delay(2000);
pinMode(input, INPUT);
}
void loop()
{
digitalWrite(13, HIGH); //Solonoid Valve
delay(1000);
digitalWrite(13, LOW);
delay(1000);
X = pulseIn(input, HIGH); //Water Flow Sensor
Y = pulseIn(input, LOW);
TIME = X + Y;
FREQUENCY = 1000000 / TIME;
WATER = FREQUENCY / 7.5;
LS = WATER / 60;
if (FREQUENCY >= 0)
{
if (isinf(FREQUENCY))
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("VOL. :0.00");
lcd.setCursor(0, 1);
lcd.print("TOTAL:");
lcd.print( TOTAL);
lcd.print(" L");
}
else
{
TOTAL = TOTAL + LS;
Serial.println(FREQUENCY);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("VOL.: ");
lcd.print(WATER);
lcd.print(" L/M");
lcd.setCursor(0, 1);
lcd.print("TOTAL:");
lcd.print( TOTAL);
lcd.print(" L");
}
}
delay(1000);
}