// Declare pins to be used
int thermistorPin = A0;
int ledPin = 11;
// Set the pin mode and start serial communication
void setup() {
pinMode(thermistorPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Read input value from analog in 0
int thermistorResistance = analogRead(A0);
if (thermistorResistance > 600) {
thermistorResistance = 600;
} else if (thermistorResistance < 300) {
thermistorResistance = 300;
}
// Use map to set the brightness of the LED
int ledBrightness = map(thermistorResistance, 300, 600, 255, 0);
// Use analog write to set the brightness of the LED
analogWrite(ledPin, ledBrightness);
// Print the information.
Serial.print("Thermistor value: ");
Serial.println(thermistorResistance);
delay(500);
}