fyrus
September 11, 2021, 12:47pm
1
I manage to run a click rotary encoder with SimpleRotary library, there is no problem with the center clicked button as its working fine.
My problem is at the rotate function.
my original code is use up and down of 2 tactile button,
if (ButtonUp) {
// increase
ISOIndex++;
if (ISOIndex > MaxISOIndex) {
ISOIndex = 0;
}
} else if (ButtonDown) {
// decrease
if (ISOIndex > 0) {
ISOIndex--;
}
When i try the encoder
int rotate = rotary.rotate();
if (rotate == 1) {
// increase ISO
ISOIndex++;
if (ISOIndex > MaxISOIndex) {
ISOIndex = 0;
}
} else if (rotate == 2) {
// decrease
if (ISOIndex > 0) {
ISOIndex--;
}
its just wont work, it detect a twist but it show a random value, it is a value in my code but randomly selected of up and down value.
It theres a way to set the encoder as a click anyway? One detent as one click?
6v6gt
September 11, 2021, 3:46pm
3
Are you attempting to simulate a rotary encoder with two tactile buttons ?
You'll have a problem because it is not a simple matter of pressing one button for clockwise and the other for anti-clockwise.
You have to get the overlap correct. At certain points, two buttons must be pressed simultaneously.
Do a quick search for rotary encoder to see how it has to work. Here, for example: https://howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/
Hi @fyrus
to facilitate our help work, publish the complete schematic of your project.
Can be done freehand.
RV mineirin
fyrus:
its just wont work, it detect a twist but it show a random value, it is a value in my code but randomly selected of up and down value.
It theres a way to set the encoder as a click anyway? One detent as one click?
Post your entire code.
My guess is that your encoder pins are floating. Do you have pull ups?
Do you know how the detent positions on the encoder relate to the internal transitions. 1 detent can equal 1,2,or 4 internal transitons.
Start at the beginning.
What are you trying to do?
And what parts are you using?
fyrus
September 12, 2021, 2:17am
7
Thanks for all the replys, i think i might find the solutions, i'll update after test
system
Closed
January 10, 2022, 2:18am
8
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.