Devices & Components
40 colored male-female jumper wires
LilyPad LED Green (5pcs)
Rain Sensor
LCD screen 20x4
High brightness LED red
Arduino UNO Mini Limited Edition
piezo speaker
Hardware & Tools
Proteus Circuit Simulator
Software & Tools
Proteus 8
Arduino IDE
Project description
Code
Arduino Rain Detector Code
cpp
Run this code using Arduino IDE and upload it
1// include the library code: 2#include <LiquidCrystal.h> 3 4//LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 5 LiquidCrystal lcd(13, 12, 11, 10, 9, 8); 6 7//Define the Pin Numbers 8const int SENSOR_PIN = 2; 9const int SPEAKER_PIN = 5; 10const int RLED_PIN = 7; 11const int GLED_PIN = 6; 12 13void setup () 14{ 15 pinMode (SENSOR_PIN, INPUT); // Set the Sensor pin as INPUT 16 pinMode(SPEAKER_PIN, OUTPUT); // Set the Red LED pin as OUTPUT 17 pinMode(RLED_PIN, OUTPUT); // Set the Red LED pin as OUTPUT 18 pinMode(GLED_PIN, OUTPUT); // Set the Green LED pin as OUTPUT 19 20 lcd.begin(20, 4); // set up the LCD's number of columns and rows: 21 lcd.setCursor(0,0); // set the cursor position: 22 lcd.print("Arduino Based"); 23 lcd.setCursor(0,1); 24 lcd.print(" RAIN DETECTOR "); 25} 26void loop () 27{ 28 int Sensor_Val = digitalRead(SENSOR_PIN); //get reading from Sensor 29 30 if (Sensor_Val == HIGH) //If Sensor Detected the Rain 31 { 32 digitalWrite(RLED_PIN, HIGH); 33 digitalWrite(SPEAKER_PIN, HIGH); 34 digitalWrite(GLED_PIN, LOW); 35 36 lcd.setCursor(0, 3); 37 lcd.print(" Rain Detected "); 38 delay(100); 39 lcd.setCursor(0, 3); 40 lcd.print(" Rain Detected. "); 41 delay(100); 42 lcd.setCursor(0, 3); 43 lcd.print(" Rain Detected.. "); 44 delay(100); 45 lcd.setCursor(0, 3); 46 lcd.print(" Rain Detected... "); 47 delay(100); 48 } 49 else 50 { 51 lcd.setCursor(0, 3); 52 lcd.print(" NO RAIN "); 53 digitalWrite(RLED_PIN, LOW); 54 digitalWrite(SPEAKER_PIN, LOW); 55 digitalWrite(GLED_PIN, HIGH); 56 } 57}
Downloadable files
Arduino Rain Detector Proteus File
Download the File and run the simulation
Arduino_Rain_Sensor.zip
Rain Sensor Library for Proteus
Download it and add it to Proteus
https://www.theengineeringprojects.com/2018/07/rain-sensor-library-for-proteus.html
Comments
Only logged in users can leave comments