user84765: I am working on a project on my Arduino Uno in which I want to change the text on the LCD every time the potentiometer has been rotated. In order to do this, I have stored the angle values into an int, constantly check if the angle has been rotated enough to change the text, and if it has, print the next message. I am not sure if either my code or circuit is wrong as nothing happens at all when i rotate the potentiometer.
Here is my code so far and an image of the circuit (the innermost potentiometer is for the brightness, the one on the right is for changing the text on the LCD. I think I may have wired the second potentiometer incorrectly but I am not sure how to fix this).

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // removed 3
// set up a constant for the button
const int buttonPin = 6;
// variable to hold the value of the button
int buttonState = 0;
// variable to hold previous value of the button
//int prevbuttonState = 0;
// a variable to choose which reply will be displayed
int reply = -1;
int prevReply = -1;
int potPin = A0;
int potVal = 0;
int angle = 0;
int prevAngle = 0;
//int startTime = 0;
//int timeElasped = 0;
//int workoutTime = 0;

void setup() {
  // set up the number of columns and rows on the LCD
  lcd.begin(16, 2);

  // set up the switch pin as an input
  pinMode(buttonPin, INPUT);

  Serial.begin(9600);
  prevAngle = map(potVal,0,1023,0,300); // set prevAngle to original angle. later, code that if the angle isnt 0 tell user to reset it
  // Print a message to the LCD.
  lcd.print("Pick a");
  // set the cursor to column 0, line 1
  // line 1 is the second row, since counting begins with 0
  lcd.setCursor(0, 1);
  // print to the second line
  lcd.print("Muscle Group!");
}

void loop() {
  // check the status of the switch
  buttonState = digitalRead(buttonPin);
  potVal = analogRead(potPin);
  Serial.print("potVal: ");
  Serial.print(potVal);
  angle=map(potVal,0,1023,0,300);//used to be 179, changed to 300 assuming it equals the max angle available in the potentiometer
  Serial.print(", angle: ");
  Serial.println(angle);
  if (angle > prevAngle+69){ // if the pot has been rotated enough clockwise, display next group
    if (reply!=3)
      reply = reply+1;//provide next muscle group
    else
      reply = 0;//return to first muscle group
    /*if (prevReply==-1)
      prevReply=reply;*/
  }
  else if (angle < prevAngle-69){ // if the pot has been rotated enough counterclockwise, display prev group
    if (reply!=0 && reply!=-1)
      reply = reply-1;//provide previous muscle group
    else if (reply==0)// check if reply is still equal to -1 btw
      reply = 3;//return to last muscle group
    else if (reply==-1){
      reply = 0;
      //prevReply=reply;
    }
  }
  //prevReply = reply;
  if (buttonState == HIGH) { //if the button has been pressed, display new random exercise within muscle group that was chosen
      if (reply == 0)
        reply = random(4,6);
      if (reply == 1)
        reply = random(7,9);
      if (reply == 2)
        reply = random(10,12);
      if (reply == 3)
        reply = random(13,15);
      // clean up the screen before printing a new reply
      lcd.clear();
      // set the cursor to column 0, line 0
      lcd.setCursor(0, 0);
      // print some text
      lcd.print("Time to do some");
      // move the cursor to the second line
      lcd.setCursor(0, 1);
      delay(500);
      lcd.clear();
      lcd.setCursor(0, 0);
      /*if (workoutTime - millis() + startTime==0){
           lcd.clear();
           lcd.setCursor(0, 0);
           lcd.print("You did it!! :]"); //if reply keeps looping, stop loop once timer=0. if reply never loops, figure out how to make it loop for the timer*/
      }
      //if (prevReply != reply) // if we have chosen a new workout, change the starting time
        //startTime = millis(); // record millis() function to see how much time passes btwn start of program to start of timer
      if (prevReply != reply){
      switch (reply) { // choose a saying to print based on the value in reply
        case 0:
          lcd.print("Arms");
          break;

        case 1:
          lcd.print("Core");
          break;

        case 2:
          lcd.print("Chest");
          break;

        case 3:
          lcd.print("Legs");
          break;

        case 4:
          //workoutTime = 2400;
          lcd.print("Arm wrkt 1; " /*+ workoutTime - millis() + startTime*/); // temporary workout names, to be replaced in a later draft
          break;

        case 5:
          //workoutTime = 1200;
          lcd.print("Arm wrkt 2; " /*+ workoutTime - millis() + startTime*/);
          break;

        case 6:
          //workoutTime = 1500;
          lcd.print("Arm wrkt 3; " /*+ workoutTime - millis() + startTime*/);
          break;

        case 7:
          //workoutTime = 1800;
          lcd.print("Core wrkt 1; " /*+ workoutTime - millis() + startTime*/);
          break;

        case 8:
          //workoutTime = 900;
          lcd.print("Core wrkt 2; " /*+ workoutTime - millis() + startTime*/);
          break;
          
        case 9:
          //workoutTime = 2400;
          lcd.print("Core wrkt 3; " /*+ workoutTime - millis() + startTime*/);
          break;
         
        case 10:
          //workoutTime = 2100;
          lcd.print("Chest wrkt1; " /* + workoutTime - millis() + startTime*/);
          break;
          
        case 11:
          //workoutTime = 1200;
          lcd.print("Chest wrkt2; " /* + workoutTime - millis() + startTime*/);
          break;
          
        case 12:
          //workoutTime = 1200;
          lcd.print("Chest wrkt3; " /* + workoutTime - millis() + startTime*/);
          break;
          
        case 13:
          //workoutTime = 1500;
          lcd.print("Leg wrkt 1; " /* + workoutTime - millis() + startTime*/);
          break;

        case 14:
          //workoutTime = 2400;
          lcd.print("Leg wrkt 2; " /* + workoutTime - millis() + startTime*/);
          break;

        case 15:
          //workoutTime = 1800;
          lcd.print("Leg wrkt 3; " /*+ workoutTime - millis() + startTime*/);
          break;
        prevReply=reply;
      }
  }
  prevAngle=angle;
}


user7508: Here is a (heavily) stripped-down version of your code:
void loop() {
    potVal = analogRead(potPin);
    angle = map(potVal, 0, 1023, 0, 300);
    if (angle > prevAngle + 69) {
        // stuff...
    } else if (angle < prevAngle - 69) {
        // stuff...
    }
    // lots of more stuff...
    prevAngle = angle;
}

Imagine this executing a few thousand times a second. Each time, it
computes the angle of the potentiometer's knob, then copies the computed
angle into prevAngle. Unless you turn the pot really fast, the angle
is unlikely to change by more than 69° in that fraction of a
millisecond.
I suggest not updating prevAngle on every iteration. Instead, let
angle slowly drift away from prevAngle through many iterations of
the loop. When the two are more than 69° apart, then you take the action
you wanted to take, and only then you update prevAngle.

84765: <p>I am working on a project on my Arduino Uno in which I want to change the text on the LCD every time the potentiometer has been rotated. In order to do this, I have stored the angle values into an <code>int</code>, constantly check if the angle has been rotated enough to change the text, and if it has, print the next message. I am not sure if either my code or circuit is wrong as nothing happens at all when i rotate the potentiometer.</p>
<p>Here is my code so far and an image of the circuit (the innermost potentiometer is for the brightness, the one on the right is for changing the text on the LCD. I think I may have wired the second potentiometer incorrectly but I am not sure how to fix this).</p>
<p><a href="https://i.stack.imgur.com/Txw7H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Txw7H.png" alt="enter image description here" /></a></p>
<pre class="lang-cpp prettyprint-override"><code>#include &lt;LiquidCrystal.h&gt;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // removed 3
// set up a constant for the button
const int buttonPin = 6;
// variable to hold the value of the button
int buttonState = 0;
// variable to hold previous value of the button
//int prevbuttonState = 0;
// a variable to choose which reply will be displayed
int reply = -1;
int prevReply = -1;
int potPin = A0;
int potVal = 0;
int angle = 0;
int prevAngle = 0;
//int startTime = 0;
//int timeElasped = 0;
//int workoutTime = 0;

void setup() {
  // set up the number of columns and rows on the LCD
  lcd.begin(16, 2);

  // set up the switch pin as an input
  pinMode(buttonPin, INPUT);

  Serial.begin(9600);
  prevAngle = map(potVal,0,1023,0,300); // set prevAngle to original angle. later, code that if the angle isnt 0 tell user to reset it
  // Print a message to the LCD.
  lcd.print(&quot;Pick a&quot;);
  // set the cursor to column 0, line 1
  // line 1 is the second row, since counting begins with 0
  lcd.setCursor(0, 1);
  // print to the second line
  lcd.print(&quot;Muscle Group!&quot;);
}

void loop() {
  // check the status of the switch
  buttonState = digitalRead(buttonPin);
  potVal = analogRead(potPin);
  Serial.print(&quot;potVal: &quot;);
  Serial.print(potVal);
  angle=map(potVal,0,1023,0,300);//used to be 179, changed to 300 assuming it equals the max angle available in the potentiometer
  Serial.print(&quot;, angle: &quot;);
  Serial.println(angle);
  if (angle &gt; prevAngle+69){ // if the pot has been rotated enough clockwise, display next group
    if (reply!=3)
      reply = reply+1;//provide next muscle group
    else
      reply = 0;//return to first muscle group
    /*if (prevReply==-1)
      prevReply=reply;*/
  }
  else if (angle &lt; prevAngle-69){ // if the pot has been rotated enough counterclockwise, display prev group
    if (reply!=0 &amp;&amp; reply!=-1)
      reply = reply-1;//provide previous muscle group
    else if (reply==0)// check if reply is still equal to -1 btw
      reply = 3;//return to last muscle group
    else if (reply==-1){
      reply = 0;
      //prevReply=reply;
    }
  }
  //prevReply = reply;
  if (buttonState == HIGH) { //if the button has been pressed, display new random exercise within muscle group that was chosen
      if (reply == 0)
        reply = random(4,6);
      if (reply == 1)
        reply = random(7,9);
      if (reply == 2)
        reply = random(10,12);
      if (reply == 3)
        reply = random(13,15);
      // clean up the screen before printing a new reply
      lcd.clear();
      // set the cursor to column 0, line 0
      lcd.setCursor(0, 0);
      // print some text
      lcd.print(&quot;Time to do some&quot;);
      // move the cursor to the second line
      lcd.setCursor(0, 1);
      delay(500);
      lcd.clear();
      lcd.setCursor(0, 0);
      /*if (workoutTime - millis() + startTime==0){
           lcd.clear();
           lcd.setCursor(0, 0);
           lcd.print(&quot;You did it!! :]&quot;); //if reply keeps looping, stop loop once timer=0. if reply never loops, figure out how to make it loop for the timer*/
      }
      //if (prevReply != reply) // if we have chosen a new workout, change the starting time
        //startTime = millis(); // record millis() function to see how much time passes btwn start of program to start of timer
      if (prevReply != reply){
      switch (reply) { // choose a saying to print based on the value in reply
        case 0:
          lcd.print(&quot;Arms&quot;);
          break;

        case 1:
          lcd.print(&quot;Core&quot;);
          break;

        case 2:
          lcd.print(&quot;Chest&quot;);
          break;

        case 3:
          lcd.print(&quot;Legs&quot;);
          break;

        case 4:
          //workoutTime = 2400;
          lcd.print(&quot;Arm wrkt 1; &quot; /*+ workoutTime - millis() + startTime*/); // temporary workout names, to be replaced in a later draft
          break;

        case 5:
          //workoutTime = 1200;
          lcd.print(&quot;Arm wrkt 2; &quot; /*+ workoutTime - millis() + startTime*/);
          break;

        case 6:
          //workoutTime = 1500;
          lcd.print(&quot;Arm wrkt 3; &quot; /*+ workoutTime - millis() + startTime*/);
          break;

        case 7:
          //workoutTime = 1800;
          lcd.print(&quot;Core wrkt 1; &quot; /*+ workoutTime - millis() + startTime*/);
          break;

        case 8:
          //workoutTime = 900;
          lcd.print(&quot;Core wrkt 2; &quot; /*+ workoutTime - millis() + startTime*/);
          break;
          
        case 9:
          //workoutTime = 2400;
          lcd.print(&quot;Core wrkt 3; &quot; /*+ workoutTime - millis() + startTime*/);
          break;
         
        case 10:
          //workoutTime = 2100;
          lcd.print(&quot;Chest wrkt1; &quot; /* + workoutTime - millis() + startTime*/);
          break;
          
        case 11:
          //workoutTime = 1200;
          lcd.print(&quot;Chest wrkt2; &quot; /* + workoutTime - millis() + startTime*/);
          break;
          
        case 12:
          //workoutTime = 1200;
          lcd.print(&quot;Chest wrkt3; &quot; /* + workoutTime - millis() + startTime*/);
          break;
          
        case 13:
          //workoutTime = 1500;
          lcd.print(&quot;Leg wrkt 1; &quot; /* + workoutTime - millis() + startTime*/);
          break;

        case 14:
          //workoutTime = 2400;
          lcd.print(&quot;Leg wrkt 2; &quot; /* + workoutTime - millis() + startTime*/);
          break;

        case 15:
          //workoutTime = 1800;
          lcd.print(&quot;Leg wrkt 3; &quot; /*+ workoutTime - millis() + startTime*/);
          break;
        prevReply=reply;
      }
  }
  prevAngle=angle;
}
</code></pre>
 7508: <p>Here is a (heavily) stripped-down version of your code:</p>
<pre class="lang-cpp prettyprint-override"><code>void loop() {
    potVal = analogRead(potPin);
    angle = map(potVal, 0, 1023, 0, 300);
    if (angle &gt; prevAngle + 69) {
        // stuff...
    } else if (angle &lt; prevAngle - 69) {
        // stuff...
    }
    // lots of more stuff...
    prevAngle = angle;
}
</code></pre>
<p>Imagine this executing a few thousand times a second. Each time, it
computes the angle of the potentiometer's knob, then copies the computed
angle into <code>prevAngle</code>. Unless you turn the pot <em>really</em> fast, the angle
is unlikely to change by more than 69° in that fraction of a
millisecond.</p>
<p>I suggest <em>not</em> updating <code>prevAngle</code> on every iteration. Instead, let
<code>angle</code> slowly drift away from <code>prevAngle</code> through many iterations of
the loop. When the two are more than 69° apart, then you take the action
you wanted to take, <em>and only then</em> you update <code>prevAngle</code>.</p>
