Mar 27, 2025
18983 views
8 respects
Components and supplies
2S LiPo Battery (7.4V) or External Power Supply
Jumper-Wires
Rain Sensor Module
Arduino-Uno
5V Passive Buzzer
Apps and platforms
Webotricks
Project description
Code
1#define RAIN_SENSOR A0 2#define BUZZER 9 3 4void setup() { 5 pinMode(RAIN_SENSOR, INPUT); 6 pinMode(BUZZER, OUTPUT); 7 Serial.begin(9600); 8} 9 10void loop() { 11 int sensorValue = analogRead(RAIN_SENSOR); 12 Serial.println(sensorValue); 13 14 if (sensorValue < 102) { // Threshold for rain detection 15 digitalWrite(BUZZER, HIGH); 16 } else { 17 digitalWrite(BUZZER, LOW); 18 } 19 delay(1000); // Delay for stability 20}
Comments
Only logged in users can leave comments
webotricks
0 Followers
0 Projects
Table of contents
Intro
0