ElectroPeak
Published © GPL3+

Make a Liquid Level Indicator with Arduino

You’ll get to know about liquids level detection with Arduino. First, you’ll see some information about the water level sensor, and then...

BeginnerProtip2 hours27,208

Things used in this project

Hardware components

Arduino UNO R3
×1
ElectroPeak Water level sensor
×1
ElectroPeak Jumpers
×1
ElectroPeak Buzzer
×1

Software apps and online services

ElectroPeak Arduino IDE

Story

Read more

Code

code 1

Arduino
/* Water level sensor
 *  by Hanie Kiani
 *  https://electropeak.com/learn/   
 */
const int analogInPin = A0; 
int sensorValue = 0;

void setup() {
 Serial.begin(9600); 
}
 
void loop() {
 sensorValue = analogRead(analogInPin); 
 Serial.print("Sensor = " ); 
 Serial.print(sensorValue*100/1024); 
 Serial.println("%");
 delay(1000); 
}

Code 2

Arduino
/* 
   * Rain Detector with Water level sensor
 *  by Hanie kiani
 *  https://electropeak.com/learn/   
 */
const int sensorMin = 0;     // sensor minimum
const int sensorMax = 1024;  // sensor maximum
const int buzzer = 9;
void setup() {
  Serial.begin(9600);  
  pinMode(buzzer, OUTPUT);
}
void loop() {
int sensorReading = analogRead(A0);
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
  // range value:
  switch (range) {
 case 0:    // Sensor is wet
    Serial.println("ٌWet!");
    tone(buzzer, 5000); 
    break;
 case 1:    // Sensor getting wet
    Serial.println(" Warning");
     tone(buzzer, 1000 , 5); 
    break;
 case 2:    // Sensor dry 
    Serial.println("Dry");
    noTone(buzzer);  
    break;
  }
  delay(10);  // delay between reads
} 

Credits

ElectroPeak

ElectroPeak

57 projects • 736 followers
At ElectroPeak we want to teach you to enjoy electronics more. We offer Top-notch guides and worry-free shopping experience.

Comments