Create Your Own Arduino LED Temperature Indicator

13 May 2023 Balmiki Mandal 0 µC - µP

How To Build An Arduino LED Temperature Indicator

Temperature is one of the most important parameters to measure and monitor in environments, from industrial applications and processes to everyday cooking. In this blog post, we'll show you how to build your own Arduino LED temperature indicator. This project is simple, inexpensive and an awesome way to get started with the amazing world of Arduino.

What You'll Need

  • Arduino Uno/Nano/Duemilanove
  • 10K Ohm Variable Resistor/Potentiometer
  • piece of Heat Shrink Tubing
  • LEDs (any color)
  • Jumper Wires
  • Breadboard

Once you have all your components assembled, it's time to start building the Arduino LED temperature indicator. The first step is to connect the 10K Ohm variable resistor to breadboard, making sure that one leg of the resistor is in the same row as the other.

Resistor Connected to Breadboard

Next, connect the Arduino ground and +5V pins to the breadboard. Then, connect the 10K Ohm variable resistor to the Arduino Analog Pin 0 and the GND pin.

Arduino Pins Connected to Breadboard

Now it's time to connect the LEDs to the breadboard. Start by inserting the LEDs into the breadboard. For each LED, make sure the long (positive) leg is towards the same row as the variable resistor. Then, connect a jumper wire from the short (negative) leg of the LED to the GND pin.

LEDs Connected to Breadboard

The last step is to connect the Arduino pins to the breadboard. Connect the digital pin to the As0 pin and the Analog pin to the remaining LED leg. Finally, attach the heat shrink tubing to the remaining LED leg.

Arduino Pins Connected to Breadboard

Now your Arduino LED temperature indicator is complete! When you move the 10K Ohm resistor, you should see the LEDs light up to indicate temperature changes. With some coding and tinkering, you can now start making the most out of this amazing project!

Here is an example source code for building an Arduino LED temperature indicator:

#define LED_PIN 13  // LED pin
#define THERMISTOR_PIN A0  // Thermistor pin
#define RESISTOR_VALUE 10000  // Value of the resistor used with the thermistor
#define THERMISTOR_VOLTAGE 5.0  // Input voltage to the thermistor circuit
#define THERMISTOR_NOMINAL 10000  // Nominal resistance of the thermistor at 25 degrees Celsius
#define TEMPERATURE_NOMINAL 25.0  // Temperature at which the thermistor has nominal resistance
#define B_COEFFICIENT 3950.0  // B coefficient of the thermistor

void setup() {
  pinMode(LED_PIN, OUTPUT);  // set LED pin as output
  Serial.begin(9600);  // initialize serial communication
}

void loop() {
  int sensorValue = analogRead(THERMISTOR_PIN);  // read the value from the thermistor pin
  float resistance = RESISTOR_VALUE * (1023.0 / sensorValue - 1.0);  // calculate the resistance of the thermistor
  float temperature = 1.0 / (1.0 / (TEMPERATURE_NOMINAL + 273.15) + log(resistance / THERMISTOR_NOMINAL) / B_COEFFICIENT) - 273.15;  // calculate the temperature in Celsius

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  if (temperature < 20.0) {
    digitalWrite(LED_PIN, LOW);  // turn off LED if temperature is below 20 degrees Celsius
  } else if (temperature > 30.0) {
    digitalWrite(LED_PIN, HIGH);  // turn on LED if temperature is above 30 degrees Celsius
  } else {
    float brightness = map(temperature, 20.0, 30.0, 0, 255);  // map the temperature to LED brightness
    analogWrite(LED_PIN, brightness);  // set the LED brightness
  }

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

In this example, an LED is connected to the Arduino pin 13 for indicating the temperature, and a thermistor is connected to the analog pin A0 for measuring the temperature.

In the setup() function, the LED pin is set as an output, and serial communication is initialized at a baud rate of 9600.

In the loop() function, the analogRead() function is used to read the value from the thermistor pin. The resistance of the thermistor is then calculated using the formula for a voltage divider circuit.

The temperature in Celsius is calculated using the Steinhart-Hart equation, which uses the resistance of the thermistor to calculate the temperature. The temperature is then printed to the serial monitor using the Serial.print() function.

The if-else statements are used to turn the LED on or off based on the temperature. If the temperature is below 20 degrees Celsius, the LED is turned off. If the temperature is above 30 degrees Celsius, the LED is turned on. Otherwise, the map() function is used to map the temperature to the LED brightness, and the analogWrite() function is used to set the LED brightness.

Finally, the delay() function is used to wait for one second before reading the temperature again.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.