CircuitPlanning:
Arduino UNO R3 --> Water Level Sensor
Pins--> Vin----->+
Pins--> GND -----> -
Pins--> A0 -----> S
DevelopingtheLogicwithinConditionsOnly:
Code://Coded and Tested By:
//Sheekar Banerjee, AI-ML-IOT Solution Engineer and Researcher
int value = 0; // holds the value
int data = A0; // sensor data pin used
void setup() {
pinMode(data, INPUT);
Serial.begin(9600); //start the serial console
}
void loop() {
value = analogRead(data);
if (value<=100)
{
Serial.println("Water Level: Empty");
}
else if (value>100 && value<=400)
{
Serial.println("Water Level: Low");
}
else if (value>400 && value<=450)
{
Serial.println("Water Level: Medium");
}
else if (value>450){
Serial.println("Water Level: High");
}
delay(1000);
}
Results:SerialMonitor:
CodeforDetectingWaterLevelwithSerialPlotter:
//Coded and Tested By:
//Sheekar Banerjee, AI-ML-IOT Solution Engineer and Researcher
const int sensorPin= A0; //sensor pin connected to analog pin A0
int liquid_level;
void setup() {
Serial.begin(9600); //baud rate for data transfer in bits per second
pinMode(sensorPin, INPUT);//the liquid level sensor will be an input
}
void loop() {
liquid_level= analogRead(sensorPin); //arduino reads the value
Serial.println(liquid_level);//prints out liquid level sensor reading
delay(3000);//delays 3 Seconds
}
SerialPlotter:
0 projects • 6 followers
A motivated Computer Scientist & Engineer with years of experience over IoT, Robotic Systems, Machine Learning Algorithms and Software.
Comments
Please log in or sign up to comment.