element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Arduino
  • Products
  • More
Arduino
Arduino Forum potentiometer instead of rotary encoder
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 14 replies
  • Answers 4 answers
  • Subscribers 89 subscribers
  • Views 811 views
  • Users 0 members are here
  • help
  • digital
  • me
  • pulse
  • please
  • arduino
  • analog
Related

potentiometer instead of rotary encoder

tomstr21
tomstr21 over 5 years ago

Hello,

I have an project where i don't wanna use a rotary encoder because it has "unlimited" range of motion.

So i thought about using a potentiometer and somehow convert the analog input to digital pulse -what I mean: I need the range of pot to mean 170 pulses (if you would have a 170 ohm pot then 1ohm will be one pulse on the output)-if you're increasing the resistance it will pulse one pin and if you'll decrease it will pulse another pin-also it'll be awesome if you can change the "pulse range" with a dip switch (maybe something like 150-170-190).

I'm not programmer so I would be thankful for help.

 

 

Thanks,

Tomas Vostradovsky

  • Reply
  • Cancel
  • Cancel

Top Replies

  • fvan
    fvan over 5 years ago +2 suggested

    Why not try the following:

     

    * take a 10k pot

    * use analogRead on the Arduino to read the value

    * divide the measured value by 6 (1024 / 170), giving you your pulse value

     

    Something like that ?

     

    int potentiometer_pin…

  • beacon_dave
    beacon_dave over 5 years ago in reply to tomstr21 +2 suggested

    Ok, go here and watch tutorials 1 to 4:

     

    Jeremy Blum Arduino Tutorials

     

    and you will no longer be a 'total noob' 

     

    Tutorial 4 shows you how to check the current analogue value and do something with it…

  • beacon_dave
    beacon_dave over 5 years ago +1 suggested

    Perhaps take a look at this tutorial:

    https://www.arduino.cc/en/Tutorial/AnalogInOutSerial

     

    Connect the potentiometer wiper to the analogue input and then use the map() function to scale the range from  0…

  • D_Hersey
    0 D_Hersey over 5 years ago

    Use a 4060, perhaps.

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • tomstr21
    0 tomstr21 over 5 years ago in reply to D_Hersey

    Oh .. didn't thought about that .. how do you think I should wire it ..any suggestions?

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • fvan
    0 fvan over 5 years ago

    Why not try the following:

     

    * take a 10k pot

    * use analogRead on the Arduino to read the value

    * divide the measured value by 6 (1024 / 170), giving you your pulse value

     

    Something like that ?

     

    int potentiometer_pin = A0;
    int potentiometer_value = 0;
    int pulse_value = 0;
    
    void setup() {
    }
    
    void loop() {
      potentiometer_value = analogRead(potentiometer_pin);
      pulse_value = potentiometer_value / 6;
      
      delay(10);
    }

    • Cancel
    • Up +2 Down
    • Reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • beacon_dave
    0 beacon_dave over 5 years ago

    Perhaps take a look at this tutorial:

    https://www.arduino.cc/en/Tutorial/AnalogInOutSerial

     

    Connect the potentiometer wiper to the analogue input and then use the map() function to scale the range from  0-1023 down to 0-170

     

    You can then use code to check whether the current input value from the pot is greater or less than the previous measured value and generate your pulses.

    • Cancel
    • Up +1 Down
    • Reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • tomstr21
    0 tomstr21 over 5 years ago in reply to fvan

    that's pretty much it but only thing that i don't see in that sketch is that I need to pulse two differrent pins -one if I'm increasing and one if I'm decreasing

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • tomstr21
    0 tomstr21 over 5 years ago in reply to beacon_dave

    Great .. but I'm total noob so I don't know how to check the current value ..

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • beacon_dave
    0 beacon_dave over 5 years ago in reply to tomstr21

    Ok, go here and watch tutorials 1 to 4:

     

    Jeremy Blum Arduino Tutorials

     

    and you will no longer be a 'total noob' 

     

    Tutorial 4 shows you how to check the current analogue value and do something with it, but it sounds like you will be better of starting at the beginning.

    • Cancel
    • Up +2 Down
    • Reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • peteroakes
    0 peteroakes over 5 years ago

    Some more advanced and in my opinion detailed tutorials here Fast Track to Arduino Programming  detailing how to deal with the analog reading and other fun stuff. I am over due updating it but it is more up-to-date than Jeremy's but perhaps a bit more complex too.

     

    As far as using a rotary encoder, a simple limit trap in you code would easily deal with that

    as an example

    if value > MAXlimit, value = limit

    if value <MINLimit value = MINLimit

     

    There is nothing wrong with using a rotary encoder and there easy to use with the available libraries

    • Cancel
    • Up +1 Down
    • Reply
    • Verify Answer
    • Cancel
  • tomstr21
    0 tomstr21 over 5 years ago in reply to peteroakes

    My problem with rotary encoder is that I wanna make a pedal that for it's range of motion can develop 170(or150, or 190) pulses so if I'm about to use encoder with 24 clicks pre rev then it's obvious that it'd take more thank one revolution..so really- I need potentiometer that thru program makes pulses

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • kulky64
    0 kulky64 over 5 years ago in reply to tomstr21

    Why do you think rotary encoder can't handle your requirement? There are encoders with more than 10 000 pulses / rev. For your application encoder with 500 pulses / rev would suffice.

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
>
Element14

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 © 2022 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube