Temperature-Responsive LED Indicator: an Arduino-Based DIY Project

by barrett-booj in Circuits > Arduino

13 Views, 1 Favorites, 0 Comments

Temperature-Responsive LED Indicator: an Arduino-Based DIY Project

IMG_7219.jpg
IMG_7216.jpg
IMG_7217.jpg
IMG_7218.jpg

Introducing the Temperature-Sensitive LED Indicator, a smart and interactive way to monitor ambient temperature through vivid color changes. This compact, Arduino-powered device uses an RGB LED to instantly communicate temperature shifts, making it a perfect tool for DIY enthusiasts, students, or anyone interested in environmental sensing. When temperatures rise above a set threshold, the LED glows red, warning of heat; in a comfortable range, it shines green; and in colder conditions, it shifts to blue, signaling cooler surroundings. Built with a temperature sensor, an Arduino, and a custom-cut wooden base for a polished finish, this project not only adds aesthetic appeal to your workspace but also serves as an engaging example of practical electronics. Whether for educational purposes or for creating a personalized temperature alert system, this temperature-sensitive indicator combines technology and creativity in a hands-on project that’s fun to build and functional in use.

Supplies

Arduino Uno: A microcontroller to handle the programming logic for reading temperature and lighting up the LED.

Breadboard: Used to easily connect the components without soldering.

RGB LED: An LED with three color channels (Red, Green, and Blue) that can be combined to display different colors.

Temperature Sensor (e.g., TMP36): Analog temperature sensor used to measure the temperature.

Resistors: Choose appropriate resistor values for the RGB LED (220Ω to 330Ω) to limit the current, and one for the sensor if necessary.

Jumper Wires: Used to connect components on the breadboard to the Arduino.

Glowforge-cut Wood Square (Optional): A base to mount the breadboard for a professional look and ease of handling.

Set Up the Power and Ground Connections

1. Prepare the Power Rail: Start by placing your Arduino and breadboard in a stable setup. Identify the 5V and GND (ground) pins on the Arduino; they are located in the power section of the board, close to the edge. Connect a jumper wire from the 5V pin on the Arduino to the positive (red) rail on the breadboard. This positive rail will now carry 5 volts from the Arduino to power various components on the board.

2. Connect the Ground Rail: Similarly, take another jumper wire and connect the GND pin from the Arduino to the ground (blue) rail on the breadboard. This connection will serve as the common ground for all components. Proper grounding is essential for the circuit to function correctly.

3. Double-Check Connections: Verify that the jumper wires are securely plugged into the Arduino pins and breadboard rails. A loose connection can lead to erratic behavior or a malfunctioning circuit.

Connect the Temperature Sensor

Screenshot 2024-11-12 at 11.42.29 AM.png

1. Identify the TMP36 Pins: The TMP36 temperature sensor has three pins. When facing the flat side of the sensor with the pins pointing downward, the left pin is Vcc (5V), the middle pin is the analog output (signal), and the right pin is GND (ground).

2. Place the Sensor on the Breadboard: Insert the TMP36 into the breadboard with each pin in a separate row. This separation allows you to connect each pin individually.

3. Power the Sensor: Connect the leftmost pin of the TMP36 to the positive rail on the breadboard, which is already connected to the Arduino’s 5V pin. This connection provides power to the sensor.

4. Connect the Signal Pin: Use a jumper wire to connect the middle pin (signal output) of the TMP36 to analog pin A0 on the Arduino. This connection allows the Arduino to read the voltage output of the sensor, which corresponds to the temperature.

5. Ground the Sensor: Finally, connect the right pin of the TMP36 to the ground rail on the breadboard, linking it to the Arduino’s ground. This completes the sensor setup, ensuring it receives a stable power and ground connection.

Wire the RGB LED

Screenshot 2024-11-12 at 12.33.53 PM.png

1. Understand the RGB LED Pins: Most RGB LEDs have four pins: one common pin (either anode or cathode) and one pin for each color (Red, Green, and Blue). The longest pin is usually the common pin. In this case, we assume a common cathode LED, where the common pin connects to ground.

2. Insert the RGB LED: Place the RGB LED on the breadboard, making sure each pin occupies a different row. This placement allows for individual wiring of each pin.

3. Connect Resistors to the LED Pins: To prevent burning out the LED, connect a resistor to each color pin (Red, Green, and Blue). Use a 220Ω or 330Ω resistor. Connect each resistor directly to its respective color pin: one on the red pin, one on the green pin, and one on the blue pin.

Program the Arduino

Screenshot 2024-11-12 at 12.31.53 PM.png

1. Open the Arduino IDE: Connect your Arduino to your computer via USB and open the Arduino IDE. The IDE allows you to write and upload code to the Arduino.

2. Code Setup: Copy the code you planned in Tinkercad or use the following code snippet. This code reads the temperature from the TMP36 sensor, converts it to Fahrenheit, and lights the RGB LED based on the temperature range.


const int temperaturePin = A0;

const int RED_PIN = 9;

const int BLUE_PIN = 10;

const int GREEN_PIN = 11;


void setup() {

  pinMode(RED_PIN, OUTPUT);

  pinMode(BLUE_PIN, OUTPUT);

  pinMode(GREEN_PIN, OUTPUT);

  Serial.begin(9600);

}


void loop() {

  float voltage, degreesF;

  voltage = getVoltage(temperaturePin);

  degreesF = ((voltage - 0.5) * 100.0) * (9.0 / 5.0) + 32.0;


  Serial.print("Temperature (F): ");

  Serial.println(degreesF);


  if (degreesF > 72) {

    digitalWrite(RED_PIN, HIGH);

    digitalWrite(BLUE_PIN, LOW);

    digitalWrite(GREEN_PIN, LOW);

  } else if (degreesF >= 65 && degreesF <= 72) {

    digitalWrite(RED_PIN, LOW);

    digitalWrite(BLUE_PIN, LOW);

    digitalWrite(GREEN_PIN, HIGH);

  } else {

    digitalWrite(RED_PIN, LOW);

    digitalWrite(BLUE_PIN, HIGH);

    digitalWrite(GREEN_PIN, LOW);

  }

  delay(1000); // Update every second

}


float getVoltage(int pin) {

  return (analogRead(pin) * 0.004882814);

}


3. Upload the Code: Click the “Upload” button in the IDE to transfer the code to the Arduino. Once the upload completes, the program will start running automatically.

4. Observe Serial Output (Optional): Open the Serial Monitor in the IDE (Tools > Serial Monitor) to see real-time temperature readings in Fahrenheit. This output helps you confirm that the sensor is working correctly.

Test and Mount the Circuit

1. Test the LED Response: With the circuit powered on, observe the RGB LED. It should change color based on the ambient temperature:

• If the temperature is above 72°F, the LED will light up red.

• If the temperature is between 65°F and 73°F, the LED will light up green.

• If the temperature is below 65°F, the LED will light up blue.

Adjust the temperature around the sensor to test each range. For instance, use a cold object near the sensor to lower the temperature or gently warm it with your hands.

2. Troubleshoot if Needed: If the LED colors aren’t changing as expected, double-check the wiring and code. Ensure all connections are secure and that the TMP36 and RGB LED pins are correctly aligned.

3. Mount the Circuit on Wood (Optional): For a polished look, mount the breadboard on the Glowforge-cut wood square. Apply a few dabs of hot glue to the back of the breadboard and press it onto the wood square. This setup gives the circuit a professional finish and makes it easy to handle.

4. Final Observation: Once mounted, you should have a neat, portable temperature indicator that changes LED colors based on the surrounding temperature.

What I Learned

Through building this temperature-sensitive LED indicator, I gained valuable insights into several key concepts in electronics, programming, and project design. Working with an Arduino Uno introduced me to microcontrollers, these small computers designed to control electronic devices, and helped me understand how they interact with components like sensors and LEDs. Using the temperature sensor, like the TMP36, taught me about analog-to-digital conversion (ADC) as I saw how the Arduino reads continuous analog signals and converts them into digital values for processing. Programming the LED’s color change based on temperature thresholds required me to use conditional statements, giving me experience with core programming concepts such as loops and functions. Assembling this circuit on a breadboard helped me grasp the fundamentals of circuit design, including organizing wiring, using resistors to control current, and ensuring stable connections. Debugging issues, like unexpected LED colors or unstable readings, honed my troubleshooting skills, teaching me to systematically test each part of the setup to isolate problems. Customizing the project by using a Glowforge laser engraver to create a wooden mount added an aesthetic element, blending my technical skills with a bit of creative thinking. This step encouraged me to consider the physical presentation and usability of my design. Successfully completing this project boosted my confidence in DIY electronics, providing me with a solid foundation in each stage of the project lifecycle—planning, coding, wiring, and testing—that I can apply to future endeavors. Overall, this hands-on project offered a comprehensive introduction to microcontroller basics, programming logic, circuit design, and creative customization, sparking new ideas for using temperature sensors, RGB LEDs, and Arduino in future projects.