Now we are going to learn how to make a rain detector with only a LCD and a microcontroller to control your hole circuit. This controller will give you the data that what is the speed of the rain. You can also make a circuit from this that to make water flowing from the pipe this will take the detail of the water flowing from the pipe and tell you the speed of the rain. You can fit it at very far places and the places where you go very less. You can place it in the office, in that office form where you cannot see outside you cannot tell or predict the speed of rain like if you are in a hall or in the mall. You can make a automatic system which can help you to work in the further process. So let’s begin.

Project Source Code
###
// Program to make a Rain detector with Microcontroller 8051 from Salman #include<REG52X2.H> sbit rs=P1^0; //register select pin sbit rw=P1^1; //read/write pin sbit e=P1^2; //enable pin sbit firs=P3^0; //pin connected to 1st level of pipe sbit seco=P3^1; //pin connected to 2nd level of pipe sbit thir_3=P3^2; //pin connected to 3rd level of pipe sbit fort=P3^3; //pin connected to 4th level of pipe sbit spkr_on=P3^4; sbit spkr_off=P3^5; // pin to off speaker
void delay(int k) //delay function
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<1275;j++);
}void write(int j) //write function
{
rs=1; //selecting command register
rw=0; //selecting to write
P2=j; //putting value on the pins
e=1; //strobe the enable pin
delay(1);
e=0;
return;
}void cmd(int j) //command function
{
P2=j; //put the value on pins
rs=0; //selecting command register
rw=0; //selecting to write
e=1; //strobe enable pin
delay(1);
e=0;
return;
}void puts(char *a) //puts function to print a string
{
unsigned int p=0;
for(;a[p]!=0;p++)
write(a[p]);
}void lcd_init(void) // function to initialise the LCD
{
cmd(0x38); //setting 8-bit interface, 2 lines, 5*7 Pixels
delay(1);
cmd(0x0e); //turning on underline visible cursor
delay(1);
cmd(0x01); //clearing screen
cmd(0x80); //moving cursor to the begining of line 1 of LCD
}void main()
{
firs=seco=thir=fort=spkr_off=1; //configuring as input pins
firs=seco=thir=fort=spkr_off=0; //lowering input pins
spkr_on=1; // making speaker on pin high,as it works on negative logic
while(1)
{
while(firs==0&&seco==0&&thir==0&&fort==0&&spkr_off==0) //condition when pipe is empty
{
lcd_init(); // initialising LCD
puts("No Rain"); //printing No Rain on lcd
}
while(firs==1&&seco==0&&thir==0&&fort==0&&spkr_off==1) //condition when 1st level
{
lcd_init();
puts("Slow"); //printing Slow on lcd
}
while(firs==1&&seco==1&&thir==0&&fort==0&&spkr_off==1) //condition when 2nd level
{
lcd_init();
puts("Moderate"); //printing Moderate on lcd
}
while(firs==1&&seco==1&&thir==1&&fort==0&&spkr_off==1) //condition when 3rd level
{
lcd_init();
puts("High"); //printing High on lcd
}
while(firs==1&&seco==1&&thir==1&&fort==1&&spkr_off==1) //condition when 4th level
{
lcd_init();
puts("fort;Very High"); //printing Very High on lcd
spkr_on=0;// Enabling speaker
}
while(firs==1&&seco==1&&thir==1&&fort==1&&spkr_on==0&&spkr_off==1)//enabling high speaker_off pin
{
spkr_on=1;//disabling speaker
}
}
}###
Circuit Diagrams
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.