Datasheet

7
6. Usage
6.1 With Arduino
Connect the module to the Basic board using any of the digital pin. You can gain the value of the
signal pin. When there is water on the bare conducting wires, the value is LOW. Otherwise, it will
be HIGH.
The following sketch demonstrates a simple application of using the Water sensor to control the
buzzer. As the picture on the below indicates, the Water sensor is connected to digital port 8 of
the Grove - Basic Shield and the Buzzer is connected to digital port 12. When there is water on
the bare conducting wires, the SIG pin output a LOW voltage. Then the Buzzer sounds. The
hardware installation is as follows:
Then connect Arduino to PC by using a USB cable.
Copy and paste code below to a new Arduino sketch.
/*macro definition of water sensor and the buzzer*/
#define WATER_SENSOR 8
#define BUZZER 12
void setup()
{
pins_init();
}
void loop()
{
if(isExposedToWater())
soundAlarm();
}
void pins_init()