Wednesday, June 29, 2016

YL-83 Rain Sensor


The YL-83 is a raindrop module that consists of 4 pins: VCC, GND, D0, and A0. The connections are self-explanatory. The LM393 IC acts as a resistive divider. The board comes equipped with a power indicator light and a LED indicating lamp. The potentiometer on the board can be used to adjust the reference voltage. In this simple project, the D0 digital pin is connected to the D7 pin of an Arduino Uno. The A0 analog pin is wired to the Arduino's A0 pin. The output signal from the analog pin gets lower when raindrop is detected. The opposite applies when the sensor is dry.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
int ledPin=13;
int sensorDPin=7;
int sensorAPin=A0;
int val;

void setup() {
  Serial.begin (9600);
  pinMode(ledPin,OUTPUT);
  pinMode(sensorDPin,INPUT);
  pinMode(sensorAPin,INPUT);
}

void loop() {
  val=analogRead(sensorAPin);
  Serial.println(val);

  val=digitalRead(sensorDPin);
  if(val==HIGH){
    digitalWrite(ledPin,LOW);
  }
  else{
    digitalWrite(ledPin,HIGH);
  }
  
  delay(2000);
}



No comments:

Post a Comment