• 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

This Article Has Been Shared 769 Times!

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

  • Arduino 7 Segment LED Display Tutorial (TM1637 4 Digit)

    Here is Detailed Arduino 7 Segment LED Display Tutorial For the Beginners With Example Codes, Circuit Diagram Which Uses TM1637, Has 4 Digit.

  • Choosing The Correct LCD Display For Arduino Like Boards

    Choosing The Correct LCD Display For Arduino Like Boards Is Crucial For Budget, For Compatibility With Wider Range Of Board & Microcontroller.

  • Arduino Door Bell With Push Button With 3 LED

    Here is Circuit Diagram, Code, List of Components & Demonstration Video of Arduino Door Bell With Push Button With 3 LED. It is easy project.

  • Arduino LDR/Photoresistor and LED Based Light Meter

    Exactly Like Basic Sound Meter With Microphone, We Can Build Arduino LDR/Photoresistor and LED Based Light Meter. Here is circuit & code.

  • Arduino MAX 7219 CNG Basic Circuit : LED, 7 Segment Displays

    Here is How To Create Arduino MAX 7219 CNG Basic Circuit to Control LED, 7 Segment Displays in Own Custom Ways Rather Than Using Modules.

Additionally, 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

  • What is an Automatic Ethanol Fireplace February 8, 2023
  • Disadvantages of Cloud-Native Computing February 7, 2023
  • Projector Screen Basics February 6, 2023
  • What is Configuration Management February 5, 2023
  • What is ChatGPT? February 3, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Arduino Servo Motor Control With Pushbutton," in The Customize Windows, May 9, 2017, February 8, 2023, https://thecustomizewindows.com/2017/05/arduino-servo-motor-control-servo-pushbutton/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT