LUOBIN_HOMEWORK

The goal is to make a rain wiper for a glass. Whenever it detects rain, it starts wiping. This project uses water sensor, servo motor and an Arduino. Didn’t find any rubber to imitate the wiper on the windshield on a car, so instead I used a piece of transparent plastic. What to be improved is, the water doesn’t vanish because of the plastic is too loose to touch the glasses surface. This will be improved in next phase.

I saw this after doing the project..:

http://notedelhotel.blogspot.com/2009/09/someone-already-did-it-windshield-wiper.html

http://notedelhotel.blogspot.com/2009/09/someone-already-did-it-windshield-wiper.html

code____________________

//by peterobbin

//courtesy to:
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.

#include <Servo.h>

Servo wiper;
int waterPin = 1;
int waterValue = 0;
int servoPin = 2;
int pos = 90;

void setup()
{
wiper.attach(servoPin);
Serial.begin(9600);
}

void loop(){
waterValue = analogRead(waterPin);
Serial.println(waterValue);
//float servoW = map(waterValue, 0, 1024, 0, 179);
delay(100);
if (waterValue > 400 && waterValue < 650){
swipeSlow();
}
else if(waterValue >= 650){
swipeFast();
}
//swipeSlow();
}

void swipeSlow(){

for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
wiper.write(pos); // tell servo to go to position in variable ‘pos’
delay(10); // waits 15ms for the servo to reach the position
}

for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
wiper.write(pos); // tell servo to go to position in variable ‘pos’
delay(10); // waits 15ms for the servo to reach the position
}
}

void swipeFast(){

for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
wiper.write(pos); // tell servo to go to position in variable ‘pos’
delay(5); // waits 15ms for the servo to reach the position
}
for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
wiper.write(pos); // tell servo to go to position in variable ‘pos’
delay(5); // waits 15ms for the servo to reach the position
}
}

Leave a Reply

Your email address will not be published.