Go Down

Topic: Problem with rotary encoders staying within bounds (Read 315 times) previous topic - next topic

(deleted)

(deleted)

AWOL

Something went wrong with your second set of code tags; everything came out in bold

johnwasser

You put the 'Serial' and 'display' calls BEFORE the code that constrains the value.
You can use the constrain() function to add a constrain before the display code:

For example:
Code: [Select]
    else if (encoderState == DIR_CCW) 
    {
      encoderDelta[i] = -1;
      encoderPosition[i]--;
      encoderPostion[i] = constrain(encoderPostion[i], encoderMinimum[i], encoderMax[i]);
      Serial.print("encoderData CCW: "[i]);
      Serial.print(encoderPosition[i]);
      display.showNumberDec(i);
      display2.showNumberDec(encoderPosition[i]);
    }
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)


Go Up