Potentiometer as input for menu selection

Hi all,

I would try it but i am using my arduino board for my project (thinking of buying a second one... if you know a cheap one u like send me a pm)

Here is what i want to do:

I have a 16 x 2 lcd and i want to have menu options on the screen. to toggle through those i want to use a potentiometer and read the value of the middle pin of it on an analog pin on the arduino..

this is what one of the lcd screens will print:

Adjust Lighting?
X16h X14h X12H

The "X" marks the place of current selection..

i was thinking of the code and came up with something like this:

if( potv >= 0 && potv <= 256)
{
 //code here...
}
....
do this four times for four options.

What I was thinking is that if you turn the pot to a certain position, the aruduino could sense it and go to the next selection option..

Would this work, has anyone tried it? Any suggestions, send em my way :wink:

thanks !

A good way to do this is using the map() function, looks something like this

option = map(analogRead(A0), 0, 1023, 0, 5);

Turning the potmeter will give you the values 0..5 which can be easily used in the menu. More about the map function see
http://www.arduino.cc/en/Reference/Map

[edit]even better Arduino Playground - HomePage

What happens when the potentiometer is turned to the end-of-travel position, and you need to rotate it more?

What you really want to use is a digital rotary encoder, which will output pulses in a sequence to know what direction you are turning the knob, and how quickly...

They aren't any more expensive than most potentiometers, there are no end-of-travel limitations, and they are fairly easy to work with (plenty of example code for the Arduino available, too).

An example:

http://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino

thanks for all the links. This sounds better than a potentiometer.. anyone know if radioshack has them?

I don't think so, and if they did you would pay at least 10x what electronics goldmine has them for

I didn't see any of them on Radioshacks website.

But one thing you also have to remember about Electronics Goldmine.. $10 minimum order, plus shipping. So you might not want to be spending $25 just to get a "few" items you needed. But on the other hand.. if you could use extra parts.. and everyone can.. They're a good choice.

ill go to radioshack today and check it out, they didnt have em onthe website tho ..

the electronic gold mine would charge me 5usd for shipping .. serious goldmine... and i cant just drive the 5 mins and pick it up either :frowning:

ohh well... how many pins do you think ill be using with the rotary shaft encoder?

ohh hey, maybe frys electronics has em.. ill see..

i cant wait to post all the details on my project :wink: look out for it in about 2 to 3 weeks :wink:

xxlbreed :sunglasses:

so here is what i found at RS:

volume control with push switch.
37detents
500kOhms
.2W
20%tolerance

i have never used a rotary encoder but this looks like one.
it has 2 large pins on the bottom, 3 small ones.

They did have a rotary switch but it wasnt a rotary encoder (at least i dont think so) because it had about 30 pins on the bottom ! :-?

What do you think? will it work?

[edit]it does not seem to turn all the way through, but stops just like a potentiometer.. [/edit]

Note that Electronics Goldmine is in Scottsdale, so maybe within driving distance?

They don't have a retail storefront - they are web-only.

:slight_smile:

so here is what i found at RS:

xxlbreed:

Forget that Radio Shack even exists; they are sad, sad remainder of something that used to be great (though old-timers will say they really started going downhill when they started selling computers in the 1970s - but that's when I first got aquainted with 'em, and even then they were waaay better than today!).

Fry's Electronics is ok for some common parts, though finding certain parts requires some patience browsing thru the NKC (NTK? can't remember) catalog.

Take the time and go with surplus when you can; Electronic Goldmine, All Electronics, and Alltronics are my favorite online haunts. Sparkfun is good if you don't mind the markup.

If you want down-n-dirty (emphasis on the dirt!) parts, including a ton of really old-school stuff (hint: while you may find a rotary encoder, it will likely be attached to something, or very dirty, or both - and you'll need to spend some time browsing!), check out Apache Reclamation and Electronics at 3rd Avenue (roughly) and Apache Street (1 block north of the I-10 truck extension in south Phoenix).

That place has been "my haunt" for the past 18 years and counting. I personally think I keep them business sometimes, I've bought so much crap from them!

;D

If you know what you are looking for/at - you can score some awesome deals. Earlier this year I picked up a 100 MHz 2-channel Fluke CombiScope (combination analog and digital scope, with DSO and RS-232 interface) for $200.00 (factory calibrated, too). A few years back I managed to score an MITS Altair 8800 and a bunch of peripheral boards (memory, I/O, etc) for $100.00 (deal of the century, if you know anything about antique microcomputers). I once saw a small industrial robot arm there being sold for $150.00 (missed that one).

In their back warehouse, last I looked, they had a large CO2 laser cutting system (about the size of a couple of refrigerators - you're not getting that without a flatbed and a forklift). They also have a small laboratory-scale wind-tunnel (about 12 feet long).

Anybody in the greater Phoenix area involved in electronics should stop in at least once...

;D

But maybe they will permit will-call pickup?

I suppose it might be worth a shot/call; IIRC, they are located in the Airpark business district (so a straight shot up the 101 should get you there fairly quickly).

I personally have never ordered anything from them, but I wouldn't hesitate to do so because of their reputation. Which is why I consider them a favorite of mine (ok, so only for browsing so far!). I have ordered parts from both All Electronics and Alltronics, though, and have had excellent and quick service from both.

:slight_smile:

business trip to Chandler and take the corporate shuttle jet.

southwest lands here too ... :wink:

(unless you were not kidding)

I might be getting a couple of arduinos in the next month or so for christmas presents .. :wink: so ill just order it that time .. right now ill stick with a potentiometer .. that should work fine for now and who knows maybe i can make it work flawless.

I really want to go to that place like NOW!! sounds awesome, didnt know it exists!

radioshack does have those awesome circuit boards for arduino shields for 1.99 :wink:

its right next to campus so no biggi going there .. takes me 2 mins walking lol .. maybe they have a joystick kinda switch thingi that i can make work .. well see..

@cr0sh
are you involved in any phoenix engineering/electronics/... clubs?

thanks guys ! im loving this forum! you make it great!

[edit]here is the link to the control at the shack.. it clicks every time you turn it a notch.. and theres 37 such notches..

http://www.radioshack.com/product/index.jsp?productId=3012598

[/edit]

Shouldn't be oppressively hellish in the wintertime, I would hope.

Actually, its really nice here, right now (at night, its starting to get a bit "chilly", but in the day, you could wear shorts and flip-flops and be OK).

I really want to go to that place like NOW!! sounds awesome, didnt know it exists!

Most people don't. On one of my first days in school here in Phoenix (I came to Phoenix in 1991 fresh outta high school, and went to High Tech Institute - probably the worst decision I ever made - I should've gone to university), our instructor took us down there for a field trip; I've been hooked ever since.

If you go, wear old clothes and shoes. You may want to bring some gloves, or at least some handi-wipes (even if you don't touch anything - you will leave there not-so-clean!). It is closer to a junkyard than a store. They also have one of the largest collection of NOS vacuum tubes I have ever seen. Finally, they also have a section (several acres) of an outdoor junkyard located off of Lower Buckeye Road - where they keep all of their large junk (ie, you need a tractor trailer or something to move it, and they sell it by the pound as scrap).

radioshack does have those awesome circuit boards for arduino shields for 1.99

If you're talking about the multi-holed PCBs for prototyping, you can get those (4 x 3 inch) at ARE; something like 5 for a dollar or something rediculous like that (I always grab a few when I go - I've got quite a collection now).

its right next to campus so no biggi going there .. takes me 2 mins walking lol .. maybe they have a joystick kinda switch thingi that i can make work .. well see..

If you really want things to cannabalize, check out area Goodwill stores. Go on 50% off day, and make a field trip of it. You can pick up all kinds of hackable junk there, most of it under $10.00 (I've bought 3 different Playstation 2 consoles there for under $15.00 each).

@cr0sh
are you involved in any phoenix engineering/electronics/... clubs?

Nope - I'm on the westside, so getting out to anything on the east side, where everyone else seems to be is nearly impossible unless its on a weekend. Sadly, neither the "new" Arduino group now the HeatSync Labs meet on the weekends, so I am stuck.

Something else from ARE that I just remembered they have a ton of: Old Palm Pilots (some with color screens) - $5.00 each (if they're still there; they were a couple of weeks ago last time I went). They also have a large selection of motors (everything from small "stomper" motors to much larger multi-horsepower plants; AC, DC, stepper - no servos, though - though they do have real AC servos, most military surplus).

Seriously - go this weekend; their hours are something like 9am-4pm on Saturday (closed on Sunday) - they're also open on weekdays, but I can't remember the hours.

Oh - and have you checked out the ASU surplus department? They hold auctions of their stuff regularly, if you want things like pallets of old printers or such...

;D

here is the link to the control at the shack.. it clicks every time you turn it a notch.. and theres 37 such notches..

yeah - that's just a potentiometer with some detents; not a rotary encoder...

you need a really good excuse to travel physically to another site. And going to Apache Reclamation and Electronics doesn't count.

Visiting a potential lead at ASU?? hhaha :smiley:

If you're talking about the multi-holed PCBs for prototyping, you can get those (4 x 3 inch) at ARE; something like 5 for a dollar or something rediculous like that (I always grab a few when I go - I've got quite a collection now).

is are the junk thing? Im guessing.. just to clarify i meant these pcbs, they are super useful because they have the same pinout as protoshields if are has those .. IM SOOOO GOING :smiley:

http://www.radioshack.com/product/index.jsp?productId=2102845

okay i used buttons got tired of doing too much programming , switched out to one pot and one button. It works flawless right now but that got me thinking what is the problem that you guys were thinking about? I dont see it but i dont wanna miss anything ... thx :wink: