Arduino LCD display value is flickering with little movement of Potentiometer

Hi,

I am looking for guidance for following query

  • I have used 10K Bourns pot and connected to Arduino and used the formula and converted voltage into degree of angle

  • but even a little movement of Pot body, display on lcd flickers

  • all connections are securely tight

  • I checked this with various types of pot, but same result

  • is it possible to write a program, where after certain angular displacement of knob of pot, I can hold the measurement value and display on LCD screen?

pls let me know if my question is clear and any suggestion to my query.

Below is the code I wrote and tried

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

float potPin1 = A1;
float pos;
float angle;
float rad = 10.0;
float dis;

void setup()
{
lcd.begin(16, 2);
lcd.clear();

pinMode(potPin1, INPUT);
Serial.begin(9600);
}

void loop()
{
pos = analogRead(potPin1);
angle = pos * (360.0 / 1023.0);
dis = 2.0 * rad * (180.0 * 7.0 / 22.0) * sin (angle / 2.0);

lcd.setCursor(0, 0); // Sets the cursor to col 0 and row 0
lcd.print("Seal Gap in mm: "); // Prints Seal Gap: to LCD

lcd.setCursor(0, 1); // Sets the cursor to col 0 and row 1
lcd.print(dis); // Prints value of Displacement

}