Rotary Encoder Help!

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kirstenlsalo
 
Posts: 4
Joined: Mon Oct 23, 2017 7:55 pm

Rotary Encoder Help!

Post by kirstenlsalo »

I am trying to use this Adafruit Rotary Encoder (https://www.adafruit.com/product/377) with the ProTrinket 5V/16MHz (https://www.adafruit.com/product/2000) and FTDI connection.

Essentially, I am trying to learn how to use this rotary encoder, and in the future what I want my code to do is scroll through menus on a LCD and utilize the push button aspect to select an option. Currently, I am trying to figure out how to write a code which will keep track of the position of the encoder and print the position in the serial monitor. There are 24 positions that the encoder can 'click' to.

I have read so many help articles on how to use encoders, but none of it is making sense. If anyone can help me get started, I would really appreciate it.

Thank you very much!

User avatar
Franklin97355
 
Posts: 23938
Joined: Mon Apr 21, 2008 2:33 pm

Re: Rotary Encoder Help!

Post by Franklin97355 »

The encoder does not know what the position is, it just reports that the shaft has moved and in what direction.

User avatar
kirstenlsalo
 
Posts: 4
Joined: Mon Oct 23, 2017 7:55 pm

Re: Rotary Encoder Help!

Post by kirstenlsalo »

franklin97355 wrote:The encoder does not know what the position is, it just reports that the shaft has moved and in what direction.
Thanks for your quick reply. I do understand that the encoder does not know what the position is, therefore I am trying to figure out how to translate the movement of the shaft in those 24 click positions into code. I just am not sure how to write that into code. I am newer to Arduino and programming in general, and it does not really make sense to me.

User avatar
Franklin97355
 
Posts: 23938
Joined: Mon Apr 21, 2008 2:33 pm

Re: Rotary Encoder Help!

Post by Franklin97355 »

Why do you need to know the position of the encoder? What is it you are going to use that for?

User avatar
kirstenlsalo
 
Posts: 4
Joined: Mon Oct 23, 2017 7:55 pm

Re: Rotary Encoder Help!

Post by kirstenlsalo »

franklin97355 wrote:Why do you need to know the position of the encoder? What is it you are going to use that for?
Currently, I have a code which uses four buttons to control various menus and a LCD screen. I want to use a single rotary encoder in place of those four buttons, but I guess I just don't know how to do that. I thought by figuring out the position of the encoder, I would be able to eventually hook up a LCD and use the encoder to move the LCD cursor position.

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Rotary Encoder Help!

Post by kcl1s »

Most rotary encoder / display sketches just use the direction and number of clicks to increment or decrement the value or move in the menu. Just think of the knob turning as an up and down button and the center click as the enter.

Personally I like the 4 or 5 button method better.

Keith

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: Rotary Encoder Help!

Post by zener »

You will need to do the basic Arduino tutorials first to get basic Arduino skills (unless you already are up to speed on the basics of course). Then this should be of some help:

http://playground.arduino.cc/Main/RotaryEncoders

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

Return to “Arduino”