const int lm35Pin = A0;  // Connect LM35 output to analog pin A0
const int numLEDs = 10;
const int ledPins[numLEDs] = {1,2, 3, 4, 5, 6, 7, 8, 9, 10};  // Connect LEDs to digital pins
const int temperatureThresholds[numLEDs - 1] = {10, 20, 30, 40, 50, 60, 70, 80, 90};  // Temperature thresholds for each LED

void setup() {
  
  for (int i = 0; i < numLEDs; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  // Read temperature from LM35
  int temperature = analogRead(lm35Pin);
  float celsius = (temperature * 5.0 / 1024.0) * 100.0;

  // Control LEDs based on temperature
  updateLEDs(celsius);

  delay(1000);  // Delay for 1 second before reading temperature again
}

void updateLEDs(float celsius) {
  for (int i = 0; i < numLEDs; i++) {
    if (i > 0 && celsius >= temperatureThresholds[i - 1] && celsius < temperatureThresholds[i]) {
      // Turn on LEDs up to the current LED (inclusive)
      for (int j = 0; j <= i; j++) {
        digitalWrite(ledPins[j], HIGH);
      }

      // Turn off LEDs after the current LED
      for (int j = i + 1; j < numLEDs; j++) {
        digitalWrite(ledPins[j], LOW);
      }
    } else {
      // Turn off all LEDs
      digitalWrite(ledPins[i], LOW);
    }
  }
}
LM35Breakout