• 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 817 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 (22.1K 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

  • How Artificial Intelligence (AI) Is Changing The Way We Play Bingo May 16, 2022
  • Why You Need A Big Data Consultant May 15, 2022
  • The Connection Between AI And Online Slots May 13, 2022
  • How To Choose Your Niche As An Instagram Influencer May 12, 2022
  • How to Choose a Powerful Domain Name for Your New Venture May 12, 2022

About This Article

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

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

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

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