B10: Car Wiper System using Arduino and Servo Motor

AR-B10: Car Wiper System using Servo Motor

This entry is part 9 of 13 in the series Arduino Basic Circuits

Important Note: In this series, the previous project #B9 is removed due to similar content like B8.

In this code when the button is pressed, the servo motor starts rotating smoothly from 0 – 90 and then 90 – 0. When the button is released, the motor restores back to angle 0.

Now let us write the code for this project. We will understand each command line in it as given in comments in the code.

#include <Servo.h>
Servo i;
int angle = 0;
int sw = 7; // connect button between pin-7 and ground
                      
void setup()
{
  i.attach(3);
  pinMode(sw,INPUT_PULLUP);
  i.write(0);
}

void loop()
{
  while(digitalRead(sw)==LOW)
  {
    for(angle=0;angle<100;angle++)
    {
      i.write(angle);
      delay(5);
    }
    delay(100);

    for(angle=100;angle>0;angle--)
    {
      i.write(angle);
      delay(5);
    }
    delay(100);
  }
}


Circuit Diagram

B10: Car Wiper System using Arduino and Servo Motor

Important: In some cars the sweeping angle of wipers may be up to 100 degree. So you can change the value of 90 degree to 100 degree.

For more interesting circuits to build with Arduino UNO and Arduino Nano or even Arduino Mega, join our course of Arduino Robotics to learn complete programming techniques to construct any type of project in your mind.

Series Navigation<< AR-B8: Servo Motor Basic CodeB13: LED Display Down Counter with Alarm using Arduino >>
Dr. Dattaraj Vidyasagar
Dr. Dattaraj Vidyasagar

M.S. Electronics & Telecomm. (Cleveland Institute of Electronics, Ohio), Associate Member (IETE, Kolkata), Panelist on Dr. Homi Bhabha Foundation, Google certified educator (Level-1), Mentor of Change (MoC-1619) Niti Ayog, Government of India, International Robotics Trainer, Veteran of Applied Electronics since 35+ years.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
1
0
Would love your thoughts, please comment.x
()
x