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.

Share on your network!
Prof. Dattaraj Vidyasagar
Prof. Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

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