LOGIN
Pankaj Kar
Edit
Delete
Share
Report
QUESTION
  ·  Mark as Answered

I needed help with programming the chip, the program is to sense rain using a raindrop sensor and giving output to a real time car wiper motor of 12 V. please help me out.

Arduino #Uno

Arduino
0 like 
Like
Share
Satish Verma
Engineer
 · New DelhiIndia
Edit
Delete
Share
Report

First use this code to get the analog input provided by your sensor on getting wet by rain water, then use that range of values to turn on and off the motor using l293D motor driver.
The analog data pin should be connected to pin 0 for this code.The code is-

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}


void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0); 
Serial.println(sensorValue);
delay(100);
}


Now after getting the min and max values store these values in min and max variable and change the above program like this-
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}


void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0); 
Serial.println(sensorValue);

if(sensorValue>min value)
{
    // CODE TO TURN ON THE MOTOR GOES HERE.
}
if(sensorValue<min value)
{
    // CODE TO TURN OFF THE MOTOR GOES HERE.
}
delay(100);
}

1 like 
Leave a reply...
DISCOVER
CHAT
ALERTS
-2
DISCUSSIONS
-1
FEED