Incremented variable

Aim: To cycle thru 6 probe values and display them on a LCD
Problem: I am using a “for” loop to count from 0 to 5 and display the values accordingly, but i have not been able to get the format of the “temp” value line correct…see code.

void LCD() { 
  int temp; 
  for (int P=0;P<6;P++) {                                                              
  lcd.clear();
  lcd.setCursor(0,0);           
  lcd.print("Probe");
  lcd.print(P);
  lcd.print(" ");

  lcd.print(temp(P)); //this is incorrect and gives error "'temp' cannot be used as a function.
                           
  lcd.print(char(223));
  lcd.print("C");
  delay(2000);
      }
}

I have tried various different formats of this line but no luck.
Any thoughts on the correct format.
Thanks

You have declared 'temp' as a local integer variable but you're trying to use it as a function. Where does your temperature data originate and how is it stored?

lcd.print(temp(P)); //this is incorrect and gives error "'temp' cannot be used as a function.
int temp;

Yes indeed. temp is an int variable. It is not a function. You can't use it as a function.

Did you mean to use an array here?

The values are from probes connected to A0 to A5 and Yes…I realize that it is an “int” but as i mentioned I have tried many formats to no avail, this is but one of them…do you know the correct way to do this??
thanks

You are doing it so wrong that it's hard to tell what you meant. I can't help you much because you posted just a snippet instead of a complete code.

But I think what you need to do is go learn about arrays in C++. That seems to me to be what you are trying to do. But with so much good stuff already out on the internet I'm not going to write a tutorial on them here.

I don't know how to explain it clearer, i want to step thru each probe value and display it on an LCD without doing this. The full code is to long to post-over 9000 chr.. the variables are defined in the full code as "double temp0;" etc. The rest of the code is fine, i just want neaten this section up.

  lcd.clear();
  lcd.setCursor(0,0);           //Start at character 0 on line 0
  lcd.print("Probe0= ");
  lcd.print(temp0);                      
  lcd.print(char(223));
  lcd.print("C");
  delay(2000);
                                                              
  lcd.clear();
  lcd.setCursor(0,0);           //Start at character 0 on line 0
  lcd.print("Probe1= ");
  lcd.print(temp1);                            
  lcd.print(char(223));
  lcd.print("C");
  delay(2000);
                                                             
  lcd.clear();
  lcd.setCursor(0,0);           //Start at character 0 on line 0
  lcd.print("Probe2= ");
  lcd.print(temp2);                            
  lcd.print(char(223));
  lcd.print("C");
  delay(2000);

When you find yourself numbering variables then it is time to learn about...

Let me say it one more time...

ARRAYS

That's how you make it work.

Now go look for a tutorial on arrays in C++.

thanks for your help....Closed