Reputation: 13
First sorry for my bad english and I hope u understand what I mean
I want make something with arduino Uno that makes a pwm signal with 50% duty cycle and variable frequency between 10 hz and 2Khz on pin 13
I want to set the frequency with an rotary encoder in such way that when I rotate the encoder one step to left, it likes up button pressed and when I rotate it one step to right it likes down button pressed
I don't want there is a counter, when I rotate to left counter+1 and when I rotate to right counter-1
I don't want the location of encoder between -infinite to 0 to +infinite
I want it do like two buttons
I hope u understand what I want
Upvotes: 0
Views: 681
Reputation: 3736
With Encoder library by Paul Stoffregen available in Library Manager, you can reset the count with encoder.write(0)
.
int direction = encoder.read();
if (abs(direction) >= ENCODER_PULSES_PER_STEP) {
if (direction > 0) {
// do something for step up
} else {
// do something for step down
}
encoder.write(0);
}
Upvotes: 1