WORKING PROCESS

From Medien Wiki
Revision as of 21:49, 14 December 2022 by Jemthemisfit (talk | contribs) (Created page with " =='''WORKING PROCESS'''== ''SENSORS AND SENSING'' 1.12.2022 '''water sensor''' https://lastminuteengineers.com/water-level-sensor-arduino-tutorial/ The water sensor is use...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WORKING PROCESS

SENSORS AND SENSING

1.12.2022 water sensor https://lastminuteengineers.com/water-level-sensor-arduino-tutorial/

The water sensor is used to detect the presence of water and is typically used to monitor water levels, detect the presence of water or leaks in spaces that need to be kept dry or detect rain fall. The water sensor is essentially a variable resistor that has more or less resistance depending on the amount of water it comes in contact with. It works very well at detecting the presence of water but the jump to the maximum range very quickly when more than a few drops of water are applied.

To connect the Arduino, water sensor and three LED's to indicate the amount of water present I followed the circuit diagram and code here: https://create.arduino.cc/projecthub/123lYT/simple-water-level-sensor-with-led-ebf3f7

In this example the sensor is being used as a rain indicator, so three states were defined: Dry Weather, Average rain and Heavy rain. Depending on the level of water present one of three LED lights would turn on and a corresponding message would be printed in the Arduino console.


int blue=2;
int red=3;
int white=4;

void setup () {
  pinMode (blue,OUTPUT);
  pinMode (red,OUTPUT);
  pinMode (white,OUTPUT);
  Serial.begin (9600);}
 
void loop() {
  // read the input on analog pin 0:
  int value = analogRead(A0);
  Serial.println (value );
  
  if (value > 500) {
    Serial.println("Very heavy Rain");
    digitalWrite (blue,LOW);
    digitalWrite(red,HIGH);
    digitalWrite(white,HIGH);}
  else if ((value > 100) && (value <= 500)) {
    Serial.println("AVERAGE Rain");
    digitalWrite (red,LOW);
    digitalWrite (blue,HIGH);
    }
  else{
    Serial.println("Dry Weather");
    digitalWrite (white,LOW);
    digitalWrite (red,HIGH);
    digitalWrite (blue,HIGH);
  delay(100);
  }
  }