element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Linear Pot to control a servo how to adjust the travel of the dial from left to right
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 17 replies
  • Subscribers 419 subscribers
  • Views 2768 views
  • Users 0 members are here
  • linear
  • arduino_uno
  • pot
  • servo_motor_control
Related

Linear Pot to control a servo how to adjust the travel of the dial from left to right

e14 Contributor
e14 Contributor over 13 years ago

Hello....

My supplies:

Arduino UNO

TowerPro Servo

Linear Pot. (radio shack 271-1715 ( http://www.radioshack.com/product/index.jsp?productId=2062354#inTheBox ))

Sketch being used: Arduino / File / Example / Servos / Knob

*******************************************

Ok hope the supplies help you, help me image

 

Everything works wonderful using this example, but my question is:

The lineear pot turns from left to right about, maybe 350°, in laymen terms picture a clock 7 being the start, 5 being the stop.

The servo will turn, when the pot is turned, but it seems as though the servo does NOT star moving until (using the example above until 11, and completes its travels upto 1) sorry for using this as an example, but its the best way to paint the picture.

So can someone tell me what I need to do in order to get the servo to start turning say around 8 and stop right around say 4?

here is the code if you are unfamiliar with it:

// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}

 

Thanks for your help...

Tony

  • Sign in to reply
  • Cancel

Top Replies

  • billabott
    billabott over 13 years ago in reply to e14 Contributor +1
    Wanna be an EE? Then I recommend you use quadrille paper for the photos next time. That goes for everyone.
  • mcb1
    mcb1 over 13 years ago in reply to billabott +1
    The other option would be to output each of the ADC readings at every hour position. This would then give some figures to set the servo output to. The code is straight from the example on the arduino site…
  • mcb1
    mcb1 over 13 years ago in reply to billabott +1
    Funny while looking at the other servo issue, I had the same idea.... You can specify the max and min pwm values, and this may be a way of overcoming the problem. You'll need to either find someones elses…
Parents
  • billabott
    0 billabott over 13 years ago

    I discovered what I consider a valuable piece of data at http://arduino.cc/en/Reference/ServoWriteMicroseconds.  It notes that some servo manufactures do not follow standards very closely so that servos often respond to values between 700 and 2300 instead of the standard 1000 to 2000.

     

    What does this mean?  Well, 1500 may be the center point for both types of servo; but, Sevro.h is only going to be sending out PWM that corresponds to 1000 to 2000.  Doing the math quickly in my head tells me that your non-standard standard servo will only travel 62.5 percent of its capacity.  Therefore you loose 37.5 percent of its capacity. 

     

    Yes, I realize that the way you have described it the servo is apparently set up to do 0 to 3000.  Maybe it is.  I really don't know.

     

    And that, my friend, explains the particular difficulty you are having with your servos.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • billabott
    0 billabott over 13 years ago

    I discovered what I consider a valuable piece of data at http://arduino.cc/en/Reference/ServoWriteMicroseconds.  It notes that some servo manufactures do not follow standards very closely so that servos often respond to values between 700 and 2300 instead of the standard 1000 to 2000.

     

    What does this mean?  Well, 1500 may be the center point for both types of servo; but, Sevro.h is only going to be sending out PWM that corresponds to 1000 to 2000.  Doing the math quickly in my head tells me that your non-standard standard servo will only travel 62.5 percent of its capacity.  Therefore you loose 37.5 percent of its capacity. 

     

    Yes, I realize that the way you have described it the servo is apparently set up to do 0 to 3000.  Maybe it is.  I really don't know.

     

    And that, my friend, explains the particular difficulty you are having with your servos.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • mcb1
    0 mcb1 over 13 years ago in reply to billabott

    Funny while looking at the other servo issue, I had the same idea....

     

    You can specify the max and min pwm values, and this may be a way of overcoming the problem.

     

    You'll need to either find someones elses code that dealt with them, or experiment yourself, by plugging the value into the sketch, and observicng when it stops moving.

     

    I'd start at the nominal centre of 1500 and slowly step it back until it no longer moves.

    Then repeat the other way.

     

    This should give you a range the servo works over.

     

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube