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 411 subscribers
  • Views 2431 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

Former Member
Former Member over 12 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 12 years ago in reply to Former Member +1
    Wanna be an EE? Then I recommend you use quadrille paper for the photos next time. That goes for everyone.
  • mcb1
    mcb1 over 12 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 12 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 12 years ago

    Do you have any idea what the following means?

     

    Operating Speed (4.8V no load): 0.12sec/60 degrees

     

    0.120 seconds = 120 ms (milleseconds)

     

    The 12 ms your delay() is using is not adequate, a bare minimum would be some where between 360 ms and 100 ms.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to billabott

    In response to billabbott from #6 comment:

    Do you have any idea what the following means?

     

    Operating Speed (4.8V no load): 0.12sec/60 degrees <-- I believe this means at 4.8 volts with no load it will take the servo 0.12sec to turn 60° from its starting point.  Which means that I would need to take into account the weight I am trying to move with the servo - that answer is approximately 00.6 ounces (17.01 grams)

     

    The 12 ms your delay() is using is not adequate, a bare minimum would be some where between 360 ms and 100 ms. <--- I agree with you that the 12 ms delay is not adequate, but there was no servo hooked up at this time.  I was doing readings from the serial monitor.  But I did perform the following test per your suggestion. 

     

    My multimeter registered the following:

     

    With the + probe on pin 1+ (see pic above), and - probe on 2 Sig. (Signal see pic) I registered the following volts:

    Complete left or what I refer to as 7 o'clock, I registered 4.4 volts, as I turned the dial / knob towards the right, to 12 o'clock, the volts dropped down 2.4 volts (thats a good thing) and to complete the travel all the way to 4 o'clock it registered 0 volts.

     

    Now with keeping the - probe on the 2 Sig, and moving the + probe to 3-, I received the following:

    Complete left or what I refer to as 7 o'clock, I registered 0.0 volts, as I turned the dial / knob towards the right, to 12 o'clock, the volts dropped increased to 2.0 volts (thats a good thing) and to complete the travel all the way to 4 o'clock it registered 4.3 volts.

     

    Hope that helped you

    Tony

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 12 years ago in reply to Former Member

    Thank for sharing your test results.  Your report does remove most of the doubt about it not being a linear pot. I am no expert with regards to servo motors. I do like to think that this experience helping you will challenge me, the co-learner, to sort it out and advance my knowledge.  There is only one case that I can think of that fits the reported data.  And that can be tested with the multimeter's ohmmeter mode.  Please recall that what you wanted originally was an explanation as to why the pot servo was not moving unless the pot knob was between 11 and 1 o'clock positions.  We are trying to get to that with the following experiment:

     

    With NO application of power to the pot (remove it from the circuit); put the ohmmeter probes on pins 1 an 2 of the pot and record the measured resistance at every o'clock position from 7 to 4.  That is every 30 degrees. Then do it again with pins 2 and 3 (results will be reversed).  In a perfect world it would go 0K, 1K, 2K, 3K, 4K, 5K, 6K, 7K, 8K, 9K, 10K ohms.    Please report back with the results.

     

    There is an arduino sketch at http://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors where by you can certify the correct funtion of your servo if you want to try it.

     

    Don't miss this part of that tutorial: http://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/if-the-servo-misbehaves.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 12 years ago in reply to Former Member

    Wanna be an EE?  Then I recommend you use quadrille paper for the photos next time. 

     

    image That goes for everyone. image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to billabott

    Ok, so the results are correct.

    I did locate the center of the switch earlier today.  I was really happy to find out the following..

    Potpin1+ and Sel -

    Starting from the left

    I show 10.1

    at my middle mark, I showed 5.1

    and at the far right I showed 0

     

    With Potpin 3+ and Sel -

    Starting from the left

    I showed 0

    at my middle mark, I showed 5.0

    and at the far right I showed 10.2

     

    Its 1135pm e/t...and I am wiped out...

    I am pretty happy with the results...You?

    I also found you previous emails very insightful, and look forward to viewing the other one

    will check out in the A.M.

    Heading to bed...

    Tony

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 12 years ago in reply to Former Member

    image  I asked you to: "record the measured resistance at every o'clock position from 7 to 4."


    It could be 0 ohms in the whole zone from 7 to 11am and 10K in the whole zone from 1pm to 5pm.  Just trying to ascertain that for every 30 degrees on the knob the resistance increases linearly 1K ohm.  And it should also increase 100 ohms for every 3 degree movement of the knob from start to finish.  33.3 ohms for 1 degree. 16.5 ohms for 0.5 degree. 1 ohm for 0.033 degree.  Smooth Linear change in resistance all along the wiper travel (ideally).

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

    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.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 12 years ago in reply to mcb1

    Indeed, that would gain some additional insight as to how to proceed.   BUT, this should not even be a problem, Mark.  The sketch should have worked correctly without all this trouble.  And, thanks again for sharing your advanced insights here.   

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

    Indeed, that would gain some additional insight as to how to proceed.   BUT, this should not even be a problem, Mark.  The sketch should have worked correctly without all this trouble.  And, thanks again for sharing your advanced insights here.   

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube