Table of Contents
Example Description
Explore the functionality of a raindrop sensor, an analog-type sensor that detects changes in resistance upon contact with water.
introduction

The raindrop sensor is an analog-type sensor that effectively measures changes in resistance when it encounters water. This property makes it an ideal choice for detecting rain and water presence in various applications. While typically designed with two pins, there are also versions available with a controller module, effectively converting it into a three-pin sensor for enhanced functionality.

rain drop sensor

Circuit

 

To set up the raindrop sensor circuit, make the following connections:

  • Sensor:
    • VCC: Connect to the 5V power supply
    • GND: Connect to ground (GND)
    • A0: Connect to analog input pin A2
  • Buzzer:
    • Buzzer+: Connect to digital pin D2
    • Buzzer-: Connect to ground (GND)

Code

  1. Add an “if-else” block from the controls palette.
  2. Insert a comparison operator into the “if” block from the operator palette
  3. Check whether the value of the raindrop sensor is below a certain threshold, let’s say 800. From the sensor palette of Quarky, add “read analog sensor () at pin () ” and place it in the blank space of the operator.
  4. If the value is below the set limit, activate the buzzer (alarm) connected to pin D2. Add set digital pin () output as () from the Quarky palette within the “if” block. In the “else” part, ensure the alarm remains off when the raindrop sensor value is above the set limit.
  5. Add the above set of code inside a “forever” block to continuously monitor the sensor’s readings.
  6. Finally, add a “when flag clicked” block at the start of the code to initiate the raindrop sensor monitoring.

Script

Output