Sustainable Development of Water
To use water in a careful manner this project can be used.
Components and supplies
1
Solderless Breadboard Half Size
1
Arduino UNO
1
Ultrasonic Sensor - HC-SR04 (Generic)
10
Jumper wires (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Code
c_cpp
1const int trig = 12; 2const int echo = 13; 3int Buzzer = 2; 4int led01 = 1; 5int led02 = 3; 6 7int t=0; 8int h=0; 9int hp=0; 10int a=0; 11 12int t2=0; 13int h2=0; 14int hp2=0; 15int b=0; 16int c=0; 17int height=28; //height of the container 18int amount=-120000; //Set your limit of water usage, it should be in ml, the value should be negative, this is for 120 liters 19void setup() 20{ 21 Serial.begin(9600); 22 pinMode(trig, OUTPUT); 23 pinMode(echo, INPUT); 24} 25 26void loop() 27{ 28 digitalWrite(trig, LOW); 29 delayMicroseconds(2); 30 digitalWrite(trig, HIGH); 31 delayMicroseconds(10); 32 digitalWrite(trig, LOW); 33 t = pulseIn(echo, HIGH); 34 h = t / height ; 35 h = h - 6; 36 h = 50 - h; 37 hp = 2 * h; 38 a = hp*10 ; 39 Serial.print("Reading 1 \ 40"); 41 Serial.print(a); 42 Serial.print(" ml \ 43"); 44 45 delay(3600000); // reading will take after one hour 46 47 48 digitalWrite(trig, LOW); 49 delayMicroseconds(2); 50 digitalWrite(trig, HIGH); 51 delayMicroseconds(10); 52 digitalWrite(trig, LOW); 53 t2 = pulseIn(echo, HIGH); 54 h2 = t2 / height; 55 h2 = h2 - 6; 56 h2 = 50 - h2; 57 hp2 = 2 * h2; 58 b = hp2*10; 59 Serial.print("Reading 2 \ 60"); 61 Serial.print(b); 62 Serial.print(" ml \ 63"); 64 delay(3600); 65 Serial.print("AMOUNT OF WATER DECREASED \ 66"); 67 c = c+(b-a); 68 Serial.print(c); 69 Serial.print(" ml \ 70"); 71 delay(1000); 72 73 if (c <= amount) 74 { 75 tone(Buzzer,500); 76 digitalWrite(led01, HIGH); 77 digitalWrite(led02, LOW); 78 } 79 else 80 { 81 digitalWrite(led02, HIGH); 82 digitalWrite(led01, LOW); 83 } 84} 85
Code
c_cpp
1const int trig = 12; 2const int echo = 13; 3int Buzzer = 2; 4int led01 = 1; 5int led02 = 3; 6 7int t=0; 8int h=0; 9int hp=0; 10int a=0; 11 12int t2=0; 13int h2=0; 14int hp2=0; 15int b=0; 16int c=0; 17int height=28; //height of the container 18int amount=-120000; //Set your limit of water usage, it should be in ml, the value should be negative, this is for 120 liters 19void setup() 20{ 21 Serial.begin(9600); 22 pinMode(trig, OUTPUT); 23 pinMode(echo, INPUT); 24} 25 26void loop() 27{ 28 digitalWrite(trig, LOW); 29 delayMicroseconds(2); 30 digitalWrite(trig, HIGH); 31 delayMicroseconds(10); 32 digitalWrite(trig, LOW); 33 t = pulseIn(echo, HIGH); 34 h = t / height ; 35 h = h - 6; 36 h = 50 - h; 37 hp = 2 * h; 38 a = hp*10 ; 39 Serial.print("Reading 1 \ 40"); 41 Serial.print(a); 42 Serial.print(" ml \ 43"); 44 45 delay(3600000); // reading will take after one hour 46 47 48 digitalWrite(trig, LOW); 49 delayMicroseconds(2); 50 digitalWrite(trig, HIGH); 51 delayMicroseconds(10); 52 digitalWrite(trig, LOW); 53 t2 = pulseIn(echo, HIGH); 54 h2 = t2 / height; 55 h2 = h2 - 6; 56 h2 = 50 - h2; 57 hp2 = 2 * h2; 58 b = hp2*10; 59 Serial.print("Reading 2 \ 60"); 61 Serial.print(b); 62 Serial.print(" ml \ 63"); 64 delay(3600); 65 Serial.print("AMOUNT OF WATER DECREASED \ 66"); 67 c = c+(b-a); 68 Serial.print(c); 69 Serial.print(" ml \ 70"); 71 delay(1000); 72 73 if (c <= amount) 74 { 75 tone(Buzzer,500); 76 digitalWrite(led01, HIGH); 77 digitalWrite(led02, LOW); 78 } 79 else 80 { 81 digitalWrite(led02, HIGH); 82 digitalWrite(led01, LOW); 83 } 84} 85
Downloadable files
SCHEMATICS
SCHEMATICS

Comments
Only logged in users can leave comments