hit a wall trying to figure how to incr/decr the value of an encoder using the Encoder Library , so far I have been able to rotate the value from 0 to 217
I like to have the encoder to increase and decrease value within a range ( 0 - 126 )
any advice is welcome
I like to have the encoder to increase and decrease value within a range ( 0 - 126 )
any advice is welcome
Code:
/* encoder Modulation**************** */
Encoder enc_Modulation(14, 15);
int value_Modulation;
long enc_Modulation_previous = -999;
int mappedMod;
/* End encoder Modulation**************** */
void Encoder_Modulation() {
value_Modulation = enc_Modulation.read();
if (value_Modulation > 127) {
enc_Modulation.write(0);
}
else if (value_Modulation < -1) {
enc_Modulation.write(127);
}
value_Modulation = constrain(value_Modulation, 1, 127);
mappedMod = map(value_Modulation, 1, 127, 40, 126);
if (value_Modulation != enc_Modulation_previous) {
enc_Modulation_previous = value_Modulation;
usbMIDI.sendControlChange(cc_Mod, mappedMod, channel);
}
}