16*2 LCD lcd.print problem

So basically i have problem that lcd.print() works only inside void setup() and in void loop() above for loop. Anything below and in for loop isn’t shown on lcd.
In my case i got Temperature written on display but not the actual wanted data (Int0, Int1 and Int2).

Does anyone know what seems to be the problem in my case? Is for loop causing this?

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

float R10 = 10;
float R110 = 110;
float U10 = 0.2418450287822511;
float U110 = 2.315468942261855;

const int num = 30;
float array0[num];
float array1[num];
float array2[num];

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(2,0);
  lcd.print("Temperature:");
}

void loop() 
{ 
  float sum0 = 0;
  float sum1 = 0;
  float sum2 = 0;
  
  for (int i = 0 ; i < 30 ; i++)
  {
  array0[num] = analogRead(A0);
  array1[num] = analogRead(A1);
  array2[num] = analogRead(A2);
  sum0 = sum0 + array0[num];
  sum1 = sum1 + array1[num];
  sum2 = sum2 + array2[num];
  delay(50);
  }
  float Vr0 = sum0/num;
  float Vr1 = sum1/num;
  float Vr2 = sum2/num;
  float V0 = Vr0 * (5.0 / 1023.0);
  float V1 = Vr1 * (5.0 / 1023.0);
  float V2 = Vr2 * (5.0 / 1023.0);
  float Int0 = R10 + ((V0 - U10)/(U110 - U10)) * (R110 - R10);
  float Int1 = R10 + ((V1 - U10)/(U110 - U10)) * (R110 - R10);
  float Int2 = R10 + ((V2 - U10)/(U110 - U10)) * (R110 - R10);
  Serial.println(Int0); 
  Serial.println(Int1);
  Serial.println(Int2);
  lcd.setCursor(0,1);
  lcd.print(Int0,2);
  lcd.print(" / ");  
  lcd.print(Int1,2);
  lcd.print(" / ");  
  lcd.print(Int2,2);
  delay(1000);

}

Does the serial.print give you the right values on the monitor? If so, I suspect, your lcd.print() command is not correct.

Printing on a lcd screen requires to set the cursor at the right position first and next lcd.print() command then prints the text or value beginning at that position - at least that's how my lcd library works.

And: if I read the syntax spec right, then you use a lcd.print() command which won't work as the syntax is: lcd.print(data, BASE); - where BASE is either BIN, DEC, OCT or HEX and NOT "2".

Hi,

yes serial.print gives the right values. Stange thing is that lcd.print("Temperature:"); in setup and in loop above for loop works and word "Temperature" is displayed on lcd.

Edit: i edited code

  lcd.setCursor(0,1);
  lcd.print(Int0);
  lcd.print(" / ");  
  lcd.print(Int1);
  lcd.print(" / ");  
  lcd.print(Int2);

But it still doesn't work.

You have to set the cursor before each single lcd.print command (there is another method, with one single command line, but let's do the straight way first.

So try this - (mightbe you have to modify the column numbers):

 lcd.setCursor(0, 1);
  lcd.print(Int0);
  lcd.setCursor(3, 1);
  lcd.print(" / ");
  lcd.setCursor(6, 1);
  lcd.print(Int1);
  lcd.setCursor(9, 1);
  lcd.print(" / ");
  lcd.setCursor(12, 1);
  lcd.print(Int2);

Thanks for help but unfortunately it does not work (i also modified column numbers).

Anarhoi:
So basically i have problem that lcd.print() works only inside void setup() and in void loop() above for loop. Anything below and in for loop isn’t shown on lcd.
In my case i got Temperature written on display but not the actual wanted data (Int0, Int1 and Int2).

Does anyone know what seems to be the problem in my case?

Your code creates many buffer overflows in RAM while accesssing arrays!

This is pure bullshit as it creaters buffer overflow:

{
  array0[num] = analogRead(A0);
  array1[num] = analogRead(A1);
  array2[num] = analogRead(A2);

The valid index of an array with 30 elements ranges from 0 to 29, NOT30!

So this would read ADC values into the last valid index position of the arrays without buffer overflow and keeping RAM intact:

{
  array0[num-1] = analogRead(A0);
  array1[num-1] = analogRead(A1);
  array2[num-1] = analogRead(A2);

In a loop with running index “i” and reading ADC values into all valid array index positions you’d possibly use:

 for (int i = 0 ; i < 30 ; i++)
  {
  array0[i] = analogRead(A0);
  array1[i] = analogRead(A1);
  array2[i] = analogRead(A2);
}

@jurs

Thank you very much! You where correct it works now (i had to change num to num-1). Can you please explain why Serial.println() prints the correct values on serial monitor?