Reading LM35 temp. sensor

This is the code for reading the lm34 sensor,it gets 8 samples and prints the min or max temperature for a more stable reading, when I compile I get the error msg
"expected primary-expression before ‘=’ token. Can anyone point me what am I doing wrong? I marked in yellow color the line that has the error, thnks…

int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
int i;

void setup()
{
Serial.begin(9600); // start serial communication
}

void loop()
{

for(i = 0;i< =7;i++){ // gets 8 samples of temperature

samples = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
_ tempc = tempc + samples*;_
_
delay(1000);_
_
}_
tempc = tempc/8.0; // better precision
tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit
if(tempc > maxi) {maxi = tempc;} // set max temperature
if(tempc < mini) {mini = tempc;} // set min temperature
Serial.print(tempc,DEC);
Serial.print(" Celsius, ");
Serial.print(tempf,DEC);
Serial.print(" fahrenheit → ");
Serial.print(maxi,DEC);
Serial.print(" Max, ");
Serial.print(mini,DEC);
Serial.println(" Min");
tempc = 0;
delay(1000); // delay before loop
_
}*_

CTRL-T does magic with the layout :wink:

  • use space where they increase the readability,
  for(i = 0; i <= 7; i++)  //most people use  < 8

furthermore the samples in the loop misses the index operator.
redid your sketch, (not tested) - check the differences
```
*int pin = 0;
float maxTemp = -100;
float  minTemp = 100;

void setup()
{
  Serial.begin(9600); // start serial communication
}

void loop()
{
  int sum = 0;
  for(int i = 0; i < 8; i++) 
  {
    sum += analogRead(pin);
    delay(1000);
  }

// do all the math at once
  float tempc = sum * 0.061035156;    // faster than    tempc = sum * 5.0 * 100.0 / 1024.0 / 8;
  float tempf = tempc * 1.8  + 32;

maxTemp = max(maxTemp, tempc);  // more readable.
  minTemp = min(minTemp, tempc);

Serial.print(tempc, 2);
  Serial.print(" Celsius, ");

Serial.print(tempf, 2);
  Serial.print(" fahrenheit → ");

Serial.print(maxTemp, 2);
  Serial.print(" Max, “);
  Serial.print(minTemp, 2);
  Serial.println(” Min");

delay(1000);
}*
```

Thank you, works splendid!

Why is i a global variable? Use global variables only where needed.