title: LCD Programming with Arduino
body: <p>I would like my LCD to display "Voltage=(sensorValue)" but right now the only way I can get the program to recognize the value as I turn the potentiometer is if I put it in a loop. But when I put it in a loop the whole screen gets filled with 1s, 2s, 3s, 4s, or 5s depending on where the potentiometer is set. </p>
  
  <p>If I don't have it in a loop then whatever setting the potentiometer is on is what will pop on the screen and will not change if potentiometer is turned.</p>
  
  <p>How can I put the results of a loop outside of a loop so I can have "(Voltage=sensoreValue)"?</p>
  
  <p>Here's my program:</p>
  
  <pre><code>#include &lt;Wire.h&gt; 
  #include &lt;LiquidCrystal_I2C.h&gt;
  
  LiquidCrystal_I2C lcd(0x27,16,2);  
  
  void setup()
  {
      lcd.init();                      
      lcd.backlight();
      int sensorPin = A0;
      int sensorValue = 0;
      sensorValue = 0.004882812 * analogRead(sensorPin) + 1;
      lcd.print("Voltage=");
  }
  
  void loop()
  {
      int sensorPin = A0;
      int sensorValue = 0;
      sensorValue = 0.004882812 * analogRead(sensorPin) + 1;
      lcd.print(sensorValue);
  }
  </code></pre>