Function only works once

I am working on a sketch to display large numbers on a 20x4 LCD.

It works great, however, when I attempt to update the value being displayed, it only updates once, on the first pass through loop.

Here is a partial code snippit:

void loop() 

{


hundreds = value / 100;
number_1 = value - hundreds * 100; //need number_1 since the value of number is destroyed
tens = number_1 / 10;
ones = number_1 - tens * 10;


// go on to print the value in large numbers

// the following  function is the last one in the  loop
// it only works once, even though value changes
//I would think that when the voltage changes, value changes, and would be updated in the display

{ 
  int val = analogRead(batteryPin);
  float volts = (val/1023.0)*referenceVolts;  
 value = volts*100;
}

}

The multiplication is to get rid of the decimal point in value. I am new to arduino, (proficient in PIC Basic Pro), and have this concept working there.

https://snippets-r-us.com/

I see nowhere in your INCOMPLETE code where you attempt to "display" anything.

As mentioned in post #1.

Always show us your ‘current’ complete sketch.
Use CTRL T to format the sketch.

Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

OK, here is all the code - I didn't post all of it because it is vert long . . . it is very long

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4);

const int batteryPin = 0;
const float referenceVolts = 4.9; 
int volts;

int j = 0;  // pointer to byte to be read from array
byte line;   // LCD LINE NUMBER
byte row;    // LCD ROW NUMBER
byte car ;   //LCD CHARACTER NUMBER
int i;      //  end pointer of the array section being displayed
int digit;
//byte x;     // offset value for rows     // used in seleting units, tens, hundreds, and thousands
byte ones;
byte tens;
int hundreds;
int number = 0;
int number_1;
int value ;
int num;


byte L_R_Ramp_Up[] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x1F, 0x1F};
byte R_L_Ramp_Dwn[] = {0x00, 0x10, 0x18, 0x1C, 0x1E, 0x1F, 0x1F, 0x1F};
byte L_R_Up_Ramp[] = {0x1F, 0x1F, 0x1F, 0x1E, 0x1C, 0x18, 0x10, 0x00};
byte R_L_Dwn_Ramp[] = {0x1F, 0x1F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00};
byte Upper_Block[] = {0X1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00};
byte Lower_Block[] = {0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F};
byte Full_Block[] =  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

//  *********  THE FIRST ARRAY SECTION IS FOR DIGIT ZERO **********

byte numberArray[] = {0, 0, 0, 0, 1, 4, 0, 2, 4, 0, 3, 1, 1, 0, 6, 1, 3, 6, 2, 0, 6, 2, 3, 6,
      3, 0, 3, 3, 1, 5, 3, 2, 5, 3, 3, 2, //  36 digits for zero (0 TO 35)

      0, 0, 8, 0, 1, 6, 1, 1, 6, 2, 1, 6, 3, 1, 6, // 15 digits  for one(36 TO 50)

      0, 0, 0, 0, 1, 4, 0, 2, 4, 0, 3, 1, 1, 2, 5, 1, 3, 4, 2, 0, 5, 2, 1, 4,
      3, 0, 6, 3, 1, 5, 3, 2, 5, 3, 3, 5, // 36 digits for two (51 TO 86)

      0, 0, 2, 0, 1, 4, 0, 2, 4, 0, 3, 1, 1, 3, 6, 2, 1, 4, 2, 2, 4, 2, 3, 6,
      3, 0, 1, 3, 1, 5, 3, 2, 5, 3, 3, 2, //  36 digits for three (87 TO 122)

      0, 0, 6, 0, 3, 6, 1, 0, 6, 1, 1, 5, 1, 2, 5, 1, 3, 6, 2, 3, 6, 3, 3, 6, // number four(123 TO 146)

      0, 0, 6, 0, 1, 4, 0, 2, 4, 0, 3, 4, 1, 0, 6, 1, 1, 5, 1, 2, 5, 2, 3, 1,
      3, 0, 5, 3, 1, 5, 3, 2, 5, 3, 3, 2, //    number five   (147 TO 182)

      0, 0, 0, 0, 1, 4, 0, 2, 4, 0, 3, 1, 1, 0, 6, 2, 0, 6, 2, 1, 4, 2, 2, 4,
      2, 3, 1, 3, 0, 3, 3, 1, 5, 3, 2, 5, 3, 3, 2, // number six  (183 TO 221)

      0, 0, 4, 0, 1, 4, 0, 3, 2, 0, 2, 4, 1, 2, 6, 2, 1, 6, 3, 0, 6, // number seven (222 TO 242)

      0, 0, 0, 0, 1, 4, 0, 2, 4, 0, 3, 1, 1, 0, 3, 1, 1, 5, 1, 2, 5, 1, 3, 2,
      2, 0, 0, 2, 3, 1, 3, 0, 3, 3, 1, 5, 3, 2, 5, 3, 3, 2, // number eight  (243 TO 284)

      0, 0, 0, 0, 1, 4, 0, 2, 4, 0, 3, 1, 1, 0, 3, 1, 1, 5, 1, 2, 5, 1, 3, 6,
      2, 3, 6, 3, 0, 3, 3, 1, 5, 3, 2, 5, 3, 3, 2};
     //  number nine(285 TO 323)

void setup() {
 
lcd.init();
lcd.backlight();
lcd.createChar(0, L_R_Ramp_Up);
lcd.createChar(1, R_L_Ramp_Dwn);
lcd.createChar(2, L_R_Up_Ramp);
lcd.createChar(3, R_L_Dwn_Ramp);
lcd.createChar(4, Upper_Block);
lcd.createChar(5, Lower_Block);
lcd.createChar(6, Full_Block);

lcd.setCursor(0, 0);
//ones = 3;
//tens = 5;
//hundreds = 7;
//value = 409;
}

void loop() 

{

hundreds = value / 100;
number_1 = value - hundreds * 100; //need number_1 since the value of number is destroyed
tens = number_1 / 10;
ones = number_1 - tens * 10;


switch (number)    // THIS POSITIONS THE THREE DIGITS
{
  case 0:
    digit = ones;
    x = 14;
    number++;
    break;
  case 1:
    digit = tens;
    x = 8;
  number++;
    break;
  case 2:
    digit = hundreds;
   x = 2;
   number++;
   break;
}

switch (digit) // THIS WRITES EACH  DIGIT : ONES, TENS, HUNDREDS
{
  case 0:
    nmbr_0();
    break;
  case 1:
    nmbr_1();
    break;
  case 2:
    nmbr_2();
    break;
  case 3:
    nmbr_3();
    break;
  case 4:
    nmbr_4();
    break;
  case 5:
    nmbr_5();
    break;
  case 6:
    nmbr_6();
    break;
  case 7:
    nmbr_7();
    break;
  case 8:
    nmbr_8();
    break;
  case 9:
    nmbr_9();
    break;

} //    *********** END OF CASE ROUTINE *******

// THIS IS WHERE THE VALUE IS UPDATED - SHOULD HAPPEN EACH LOOP - 

 { 
 int val = analogRead(batteryPin);
  float volts = (val/1023.0)*referenceVolts;  
 value = volts*100;
}

}  //  *********  END OF LOOP ***********


void nmbr_0()
{
j = 0, i = 35, write_num(); // write the large character zero/
}

void nmbr_1()
{
j = 36, i = 51, write_num();
}

void nmbr_2()
{
(j = 51, i = 86, write_num());
}

void nmbr_3()
{
j = 87, i = 122, write_num();
}

void nmbr_4()
{
j = 123, i = 146, write_num();
}

void nmbr_5()
{
j = 147, i = 182, write_num();
}

void nmbr_6()
{
j = 183, i = 221, write_num();
}

void nmbr_7()
{
j = 222, i = 242, write_num();
}

void nmbr_8()
{
j = 243, i = 284, write_num();
}

void nmbr_9()
{
j = 285, i = 323, write_num();
}

//**********************

void write_num()
{
while (j < i)
{
  line = numberArray [j];
  j++;
  row = numberArray[j];
  j++;
  car = numberArray[j];
  j++;

  lcd.setCursor(row + x, line); // WRITE EACH CHARACTER AS SELECTED VIA CASE
  lcd.write(car);

}    //********  END OF WHILE STATEMENT
}

I'm pretty sure the problem is in the switch(number){...} part.

number starts at zero

first time through loop you change it to 1
second time, you change it to 2
third time, you change it to 3

The switch(number){...} block doesn't have a case for 3 so number never changes after that.

I've no idea what you're trying to do in this part but I'm sure it's broken.

Thanks
As I stated, the sketch WORKS - - the problem is the value to display is not UPDATED.

To duplicate it, a pot would be required to change voltage hence change value.

To test it, simply block out the function that reads a voltage . (last one at the end of LOOP) Then un-block the line value - 409 just before void loop.

I only chose the voltage idea so I could develop a variable that could be easily changed.

Obviously a 20x4 LCD with I2C interface would be required.

I realize the code could probably be refined by any of the resident experts, I'm still learning.

So please, before saying the sketch does not work, try it, it works fine and the large numbers have a nice format.