• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Arduino Servo Motor Control With Pushbutton

By Abhishek Ghosh May 9, 2017 2:50 am Updated on January 3, 2018

Arduino Servo Motor Control With Pushbutton

Advertisement

This is very easy, basic but important project. Because with just a button we can actually rotate things like a knob, mechanical regulator etc. Here is Circuit Diagram, Code To Create Arduino Servo Motor Control With Pushbutton Project. We are using TowerPro SG 5010 servo motor in this project but any TowerPro servo motor will work fine. Here is video of the thing :

 

Arduino Servo Motor Control With Pushbutton : Needed Components

 

You need just the servo motor, push button switch and some obvious components like a breadboard, few jumper wires etc.

 

Arduino Servo Motor Control With Pushbutton : Circuit Diagram and Code

 

This is very easy to join the components by looking at this image (we used 1K Ohm resistor in our test) :

Advertisement

---

Arduino Servo Motor Control With Pushbutton

We have the full project on fritzing.org for you to download all the files and also the code is on Github.

Of course here is the code too :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <Servo.h>
const int servoPin = 8;  // Servo pin
const int buttonPin = 9;  // Pushbutton pin
int buttonState = 0;
int directionState = 0;
Servo myservo;
int pos = 0;
void setup() {
   myservo.attach(8);
   pinMode(buttonPin, INPUT);
}
 
void loop(){
   buttonState = digitalRead(buttonPin);
   if (directionState == 0){
     if (buttonState == HIGH) {
       directionState = 1;
       for(pos = 0; pos < 180; pos += 1)
       {
         myservo.write(pos);  
         delay(15);  // waits 15ms to reach the position
       }
     }
 
   } else if (directionState == 1) {
     if (buttonState == HIGH) {
       directionState = 0;  
      
      for (pos = 180; pos>=1; pos -=1)
       {
         myservo.write(pos);
         delay(15);
       }
     }
   }
}

 

Further Improvement Ideas

 

Previously we have shown you how to perform multitasking in Arduino Traffic Light With LED Display Timer With Push Button Switch.

Idea 1 :

Can you modify the project yourself so that normally there will be green light. When you will push the button, the green light will be off and yellow will momentarily on, then red light will be on. Also the timer will start and servo motor will start to sweep. At the end of swap, again red light will be off and green light will be on.

That kind of usage is normal safety precaution for industrial tools.

Idea 2 :

Similar setup like Idea 1 but normally there will be green light. When you will push the button, the green light will be off and yellow will momentarily on, then red light will be on and timer will start. When timer will end the servo will sweep.

That kind of usage is for making a mechanical knob digitally controlled with timer.

Tagged With controlling servo with arduino and switch , button operated motor program arduino , arduino servo button code , arduino servo push button , arduino push button code , arduino servo with one push button code , arduino push button servo control , arduino nano servo sweep button , arduino control servo with push button , arduino servo motor codes with buttons
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Arduino Servo Motor Control With Pushbutton

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Servo Motor Arduino Code : Basic

    Here is Basic Servo Motor Arduino Code to Test Newly Purchased Servo Motor or Perform Some Basic Action. We Can Fine Tune Degrees of Sweep.

  • List of Budget Saving Cheap Arduino Modules And Components

    Here Is Best List of Budget Saving Cheap Arduino Modules And Components on Web With Which You Can Create Useful Projects And Will Not Repent.

  • Arduino Blink LED With Pushbutton Control to Turn ON and Off

    Arduino Blink LED With Pushbutton Control to Turn ON and Off is Few Steps Higher Than Basic Example. There is Matter of Repeat Checking by Microcontroller.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy