How to Build a Rain Alarm System for Kids - Fun Arduino School Project With Two LED Alerts
This article titled "How to Build a Rain Alarm System for Kids - Fun Arduino School Project With Two LED Alerts" is part of the "Learn Robotics with CYFI" knowledge series by NESTA TOYS.
Article summary: What if your Arduino could detect rain before you even look out of the window? This CYFI rain alarm project uses a rain sensor and two LEDs to build a mini traffic light for the weather - green when it is dry, red the moment rain hits. Perfect for school science fairs, STEM projects, and curious kids who are ready to build something that actually makes decisions on its own!
This educational content focuses on coding, robotics, computational thinking, STEM learning, and technology education for students, parents, educators, and schools.
CYFI by NESTA TOYS is a structured learning platform that combines block-based programming, robotics simulations, hands-on activities, and a gradual transition to text-based coding using Python and C++.
What is a Rain Alarm System and How Does It Actually Work?
What if your Arduino could smell rain coming? Not literally - but almost! The CYFI Rain Alarm System can detect the very first drop of rain the moment it lands, before you even look out of the window.
Here is what makes this project really cool. Most basic rain detectors just turn on one light. This one works like a mini traffic light - a green LED glows when everything is dry and safe, and the moment rain is detected, the green switches off and a red LED lights up as an alarm. Two LEDs. One sensor. A clear signal every single time.
You will build this entire system on a breadboard using a rain sensor module and an Arduino Uno. No soldering, no complicated tools - just wires, components, and code. When rain hits the sensing pad, the red LED turns on and your laptop screen prints RAIN DETECTED. When it dries up, the green comes back on and NO RAIN appears. It is satisfying to watch and genuinely useful in real life. This is the perfect next-level Arduino project for kids who have done the basics and are ready to build something that actually makes decisions on its own.
What STEM Skills Does Your Child Learn by Building a Rain Alarm System?
This project teaches far more than just electronics. Here is what your child actually walks away with:
- How a rain sensor detects moisture and converts it into an electrical signal
- How an Arduino reads a sensor input and makes a decision based on it
- How to control two output devices - a red LED and a green LED - from one Arduino
- How to use a breadboard to build a circuit safely without soldering
- How to write, upload, and modify real Arduino code
- How electronics respond to real-world events - the foundation of all smart devices
Parent tip: This project introduces your child to input-output logic - the core concept behind every smart device, from automatic street lights to home security systems. Building it at home makes that technology feel real, not abstract.
What Are the Components Needed to Build a Rain Alarm System With Arduino?
Everything listed below is available in the CYFI kit from cyfi.nestatoys.com. Each component is beginner-safe, low-voltage, and designed for kids age 8 and above. Here is what you will need:
1. Rain Sensor Module
This comes in two parts - the stripey black sensing pad that gets wet, and the small comparator board that reads the signal. When rain hits the pad, it sends a LOW signal to the Arduino. There is a small dial on the board to adjust sensitivity.
2. Arduino Uno board
The brain of the project. It reads the rain sensor every 3 seconds, decides which LED to turn on, and sends a message to your laptop screen. All the logic lives in the code you upload.
3. Red LED
This is your rain alarm. It lights up at pin 13 the moment rain is detected. Red means danger - rain is here!
4. Green LED
This is your all-clear signal. It stays on at pin 10 when everything is dry. When the red LED turns on, the green one turns off and vice versa. Two LEDs working together like a traffic light.
5. Breadboard
All connections in this project are made on the breadboard - no soldering required. The breadboard holds your components and wires in place safely and makes it easy to change things if needed.
6. Jumper wires
Colour-coded wires to connect everything together. Red for positive, green for negative, and orange for signal wires as shown in the circuit diagram.
7. 9V Battery (optional)
You can power the Arduino via USB from your laptop, or use a 9V battery for a fully standalone build. If using a battery above 5V, add a resistor as shown in the circuit diagram.
Fun fact: The rain sensor pad works because water conducts electricity. When a raindrop bridges the copper tracks on the pad, it completes the circuit and the sensor fires. The same principle is used in professional weather stations around the world!
How Do You Connect a Rain Sensor to Arduino? Step by Step Wiring Guide
All connections in this project are made on a breadboard. Follow the colour-coded guide below carefully. Red wires = positive (+), green wires = negative (-), orange wires = signal (input or output). Use the circuit diagram image above as your visual reference.

Wire Connections - Rain Alarm System:
|
From |
To (Arduino) |
Wire Colour |
What it does |
|
Sensor D0 pin |
Pin D2 |
Orange |
Sends rain signal to Arduino |
|
Sensor VCC |
5V |
Red |
Powers the sensor |
|
Sensor GND |
GND |
Green |
Completes the circuit |
|
Red LED (+) |
Pin D13 |
Red |
Rain alarm - lights up when rain detected |
|
Green LED (+) |
Pin D10 |
Green |
All clear - stays on when no rain |
|
Both LED (-) |
GND (via breadboard) |
Green |
Negative leg of both LEDs to ground |
Parent tip: All connections are made on the breadboard - nothing is soldered. If a wire is in the wrong place, just pull it out and move it. The breadboard makes this project completely safe and beginner-friendly for kids of all ages.
Important note from the circuit diagram: If you are powering the Arduino with a battery above 5V (such as a 9V battery), add a resistor in series with the LEDs to protect them. If powering via USB from your laptop, no resistor is needed.
How Does the Rain Alarm Circuit Work? The Science Behind the Two LED System
Here is the science behind your build - explained step by step in plain language. Once your child understands this, they will see exactly how the same logic powers everything from traffic lights to fire alarms!
Step 1 - Rain hits the sensing pad
The black stripey sensing pad has two sets of tiny copper tracks. Normally they do not touch. When a raindrop lands on the pad, the water bridges the gap between the tracks - because water conducts electricity. This drops the resistance on the pad and sends a signal to the comparator board.
Step 2 - The comparator board sends a LOW signal
The small blue comparator board reads the change in resistance. When rain is detected, it pulls the D0 pin LOW (close to 0 volts). When dry, D0 stays HIGH (close to 5 volts). The small dial on the board lets you adjust how sensitive it is - turn it to detect even a light drizzle or only heavy rain.
Step 3 - The Arduino reads pin D2 every 3 seconds
The Arduino checks pin D2 every 3000 milliseconds - that is every 3 seconds. This is set by the delay(3000) command in the code. LOW on D2 means rain. HIGH means no rain. The Arduino then decides which LED to turn on based on this reading.
Step 4 - The two LEDs switch based on rain status
This is what makes this project special. When rain is detected, the Arduino turns the RED LED on (pin 13) and the GREEN LED off (pin 10), and prints RAIN DETECTED on the Serial Monitor. When it is dry, the GREEN LED turns on and the RED LED turns off, and NO RAIN is printed. Two LEDs. One sensor. Clear signal every time.
Step 5 - The Serial Monitor confirms everything on screen
Open the Serial Monitor in Arduino IDE and you will see RAIN DETECTED or NO RAIN printing every 3 seconds. This is great for your project report - you can show your teacher a live log of the sensor readings during your test.
Arduino Code for Rain Alarm System - Copy, Upload and Watch It Work
// Rain Sensor + LEDS
const int rainPin = 2; // D0 from sensor
const int greenled = 10; // GREEN LED
const int redledPin = 13; // LED
void setup() {
pinMode(rainPin, INPUT);
pinMode(redledPin, OUTPUT);
pinMode(greenled, OUTPUT);
Serial.begin(9600);
}
void loop() {
int rainState = digitalRead(rainPin);
// Most sensors: LOW = Rain detected
if (rainState == LOW) {
digitalWrite(redledPin, HIGH); // LED ON
digitalWrite(greenled, LOW);
Serial.println("RAIN DETECTED");
} else {
digitalWrite(redledPin, LOW); // LED OFF
digitalWrite(greenled, HIGH);
Serial.println("NO RAIN");
}
delay(3000); }
Fun fact: Try changing delay(3000) to delay(500) in the code and uploading again. Now the sensor checks for rain every half a second instead of every 3 seconds - much more responsive! This is how real weather monitoring systems work, checking sensors dozens of times per second.
How to Use This Rain Alarm System for a School Science Project or STEM Exhibition
This rain alarm Arduino project is perfect for school science fairs, STEM exhibitions, holiday project work, and robotics competitions. It is easy to demonstrate live and always impresses teachers and judges. Here is exactly how to go from build to exhibition-ready:
Step 1 - Upload the Code Using Arduino IDE
Download the free Arduino IDE app from arduino.cc. Open it and paste in the code from Section 5 above. Connect your Arduino Uno to your laptop using a USB cable. In Arduino IDE, go to Tools > Board > Arduino Uno, select the correct COM port, and click the Upload button (the right-pointing arrow icon). The code will upload in seconds.
Step 2 - Open the Serial Monitor to See Live Readings
Once uploaded, go to Tools > Serial Monitor in Arduino IDE. Set the baud rate at the bottom right to 9600. You will see NO RAIN printing on screen every 3 seconds as long as the pad is dry. This confirms everything is working correctly before you test with water.
Step 3 - Test it With Water and Watch Both LEDs
Gently drip a few drops of water onto the black sensing pad. Watch the green LED turn off and the red LED light up and the Serial Monitor switch to RAIN DETECTED. Dry the pad with a tissue. Watch the red LED turn off and the green LED come back on. That is your rain alarm working exactly as designed. Show this live at your exhibition!
Step 4 - Write Your Project Report
A strong school project report on this topic should cover:
- The real-world problem you are solving - protecting clothes, gardens, open windows from sudden rain
- A list of all components and what each one does
- How the circuit works - use Section 5 above as your explanation
- Your test results - how many drops triggered the red LED? Did sensitivity adjustment change anything?
- What you would add or improve next time
What Are the Best Ways to Make This Project Even Better?
- Add a buzzer to pin 8 that beeps when the red LED turns on - a proper audio alarm
- Add an LCD screen that displays RAIN ALERT in large text when triggered
- Add a third yellow LED for light drizzle and red only for heavy rain using analogRead
- Connect a servo motor that closes a pretend window automatically when rain is detected
- Use the millis() function to log exactly how long it has been raining
Exhibition tip: Bring a small spray bottle to your school stall. When visitors walk up, spray a light mist on the sensing pad and let them watch the green LED switch to red in real time. Then hand them a tissue to dry the pad and watch it switch back. Making the audience part of the demo is what wins at science fairs!
This project is part of the CYFI x Nesta Toys Arduino Beginner Kit. Made for curious kids and hands-on parents. Get your CYFI kit at cyfi.nestatoys.com