Arduino Code for Water Detector / Sensor
Here is the pseudocode and code for making an ultrasonic Sensor using Arduino.
Pseudocode
Firstly, we need to initialize the constants that denote the pins to be used.
Define the pins that will be made for generating input and output.
The water sensor is connected to
PIN number 8 of Arduino.
The LED is also connected to digital PIN 9. The water sensor is connected to the input PIN and the LED is
connected at the output.
The water sensor is programmed to turn LOW when the water level is detected.
The Arduino is programmed to light the LED when the water level is detected. It also generates a buzzing
noise. The LED remains OFF when no water level is detected.
Code
#define Grove_Water_Sensor 8
#define LED 9
void setup() {
pinMode(Grove_Water_Sensor, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
if( digitalRead(Grove_Water_Sensor) == LOW) {
digitalWrite(LED,HIGH);
}else {
digitalWrite(LED,LOW);
}
}
Arduino – Water Detector / Sensor
Sensors are widely used for detecting different quantities like the presence of light, level of water, etc. One such example of a sensor is the water sensor which uses various principles of physics to detect the presence of water. This sensor is known for detecting different water levels with accuracy and precision.
This article will talk about the design of a water sensor using the Arduino board and programming software. We will study the specifications needed for this sensor, and the methods and circuit diagrams used for designing this sensor. In order to understand the functioning of the sensor, we will study the principles of the sensor. In addition to this, we will see the Arduino code written on IDE that will result in a sensor. The article will end with some frequently asked questions that can be referred to by readers.
Table of Content
- Water Sensor
- Types or Classification
- Components
- Construction
- Important Terminologies
- Working
- Arduino Code
- Advantages
- Disadvantages
- Applications