How do I code a rotary encoder to change the value of a variable in a code?
e.g.
if (distance>[value])
{
Console.WriteLine("Distance is greater than [value]");
}
[value] is the value the rotary encoder is supposed to change.
How do I code a rotary encoder to change the value of a variable in a code?
e.g.
if (distance>[value])
{
Console.WriteLine("Distance is greater than [value]");
}
[value] is the value the rotary encoder is supposed to change.
Which rotary encoder do you have? Please post a link to its spec's.
Type "encoder" in the search box of library manager, control-shift-I in the IDE; there are a few hits.
One of them is installed as part of the IDE install I think, and has examples in File / Examples.
Maybe one or other of them will be what you need; I think the installed one is for standard type quadrature encoders.
To be of real help, we need to know which encoder that you have. Otherwise we waste a lot of time with guessing games. Not all encoders are the same.
A photo of your encoder would help or a link to where you got it.
Read the forum guidelines to see what kind of information that helps us to help you.
A schematic, not a frizzy picture as how you have wired it will help. Also following groundFungus request will help us help you. Posting links to technical information on all the hardware items helps.
I use this model
https://lastminuteengineers.com/rotary-encoder-arduino-tutorial/ is one of the 1.8 million pages that come up with a search for "arduino rotary encoder".
https://howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/ is another.
The Encoder library will help with reading an encoder. It takes care of debounce.
I have been to those websites before, but how do i take the input of the rotary encoder and use it to change the value of a variable in the code?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.