Hi all,
First of all,
I tried searching on the internet to find an answer for my problem but due to lack of experience i cannot find something understanding for me...
in a midi usb project to make a midi controller i want to use some rotary encoders.
I use the Encoder.h lib from the pjrc website. this is a very easy lib to use and so i was able to get some readings on the serial monitor.
I have two questions:
- I want to limit the values between 0 and 127 i did this with the following code:
#include <Encoder.h>
// Change these two numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder myEnc(38, 40);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
if(newPosition > 127){
newPosition = 127;
}
if(newPosition < 0) {
newPosition = 0;
}
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
}
}
So my upper and lower value are limited. but for example I go "10 clicks" below 0 I also have to turn first "10 clicks" before the counting starts again. I would like to eliminate that.
This encoder gives 4 readings per "click" (I hope I say this correct). So for each "click" i get 4 readins in the searial monitor. how can i get the program to send only a reading when the encoder makes a "click"
Thanks in advance for all the help and excuse me for my bad grammar.
regards
Jazzy