Rotary Encoder example?

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
cag
 
Posts: 21
Joined: Mon Jun 18, 2012 10:34 pm

Rotary Encoder example?

Post by cag »

I'm trying to get the adafruit product 377 rotary encoder working. I've found several various examples and I'm not having any success. Can somebody point me to an example that works with that specific device?

THANKS!

A

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Rotary Encoder example?

Post by adafruit_support_mike »

There are several design choices you can make when it comes to writing code for any switch, so I can't point you to any one-size-fits-all example, but I can tell you about the options and tradeoffs, and can talk you through the process of getting the solution you choose working.

For starters, how comfortable are you with the connections on the encoder? The side with two pins is a normally-open switch, and the side with three pins is the quadrature output. You'll want to connect the center pin to GND, run 10k resistors from the two outer pins to VCC, then attach your sensors to the points where the resistors meet the pins.

cag
 
Posts: 21
Joined: Mon Jun 18, 2012 10:34 pm

Re: Rotary Encoder example?

Post by cag »

OK - that confirms that I interpreted the connections properly, and I understand the rising falling signal stuff. I was afraid I was just missing the circuit entirely somehow, but you've described what I have, so my problem must lie elsewhere. I'll keep messing with it.

All I'm trying to do is have it set a var between 0 and 512 and then roll backover to 0. It'll be cake once I get the basics working, but so far that has eluded me.

Thanks!

cag
 
Posts: 21
Joined: Mon Jun 18, 2012 10:34 pm

Re: Rotary Encoder example?

Post by cag »

I realize now that was completely vague the way I stated it. I'm connecting the encoder to a Uno - so as far as the "sensor" connections go - that could be any 2 digital pins (like 8 and 9) correct? Or am I missing that...

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Rotary Encoder example?

Post by adafruit_support_mike »

The pins you can use depend on how you want to handle the input.

If you just want to poll the input pins at a set interval, you can use any pin. If you want to use interrupts that detect "pin changed" events, you can also use any pin on an UNO. If you want to use interrupts that detect a specific condition.. a rising edge, for instance.. you're limited to pins 2 and 3.

If you want to post the code you're using I'll take a look at it and see if anything occurs to me.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”