int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int ledCount = 10;
int temp_pin = A0;
void setup() {
Serial.begin(9600);
//Setup all the LED pins
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
//setup for the temp sensor
pinMode(temp_pin, INPUT);
}
void loop(){
int temp_sensor_mapped = 0;
int temp_sensor_value = analogRead(temp_pin);
//Turn off all the LEDS
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
digitalWrite(ledPins[thisLed], LOW);
}
temp_sensor_mapped = map(temp_sensor_value,953,115,0,9);
//Selectively turn on the LEDS
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
if (thisLed<=temp_sensor_mapped) {
digitalWrite(ledPins[thisLed], HIGH);
}
else{
digitalWrite(ledPins[thisLed], LOW);
}
}
Serial.print(temp_sensor_value);
Serial.print(" ");
Serial.println(temp_sensor_mapped);
delay(100);
}