RGB LED Temperature Indicator




Introduction: RGB LED Temperature Indicator

Recently, the AC has been broken, and I've been very curious as too how how an environment can get before it begins impeding my thought process. I wanted a quick indication that tells me if the temperature is freezing, cool, mild, or searing hot, so I decided to make an RGB LED temperature indicator.

In this project the LED will change colours from blue to cyan to green to yellow to pink to red, depending on the temperature of the surrounding environment, with blue indication very cold and red indication very hot.

Step 1: Tools and Materials

  • Arduino 101 or Arduino Uno
  • 3 pieces of 100Ω Resistor
  • Temperature Sensor - TMP36
  • Jumper Wires

Step 2: Circuitry

Connecting the Arduino Power to the Breadboard. Both the temperature sensor and the RGB LED would require to be connected to a common ground and 3.3V so we will use the breadboard power rails.

  • Connect the 3.3V pin from the Arduino to the red power rail on the breadboard with a red jumper cable.
  • Connect the GND pin from the Arduino the black power rail on the breadboard with a black jumper cable.

Wiring the Temperature sensor to the Arduino

  • Connect the bottom-most pin of the temperature sensor with the flat side facing right, to 3.3V on the red power rail of the breadboard
  • Connect the top-most pin of the temperature sensor to the common ground on the black power rail of the breadboard
  • Connect the middle pin to the analog pin A0 of the Arduino .

Lastly, wiring the RGB LED to the Arduino

  • Connect the longest pin of the RGB LED to the common ground on the black power rail of the breadboard.
  • Then, connect each of the three other pins from the pin on the edge closest to ground (this is the red LED pin) to a 100Ω resistor in series to pins 5, 6, and 9 on the Arduino, respectively.

Step 3: Code

//create constants for the three analog input pins

const int redPot = 0; const int greenPot = 1; const int bluePot = 2;

//create constants for the three RGB pulse width pins const int redPin = 5; const int greenPin = 6; const int bluePin = 9;

//create variables to store the red, green and blue values int redVal; int greenVal; int blueVal;

void setup() { //set the RGB pins as outputs pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); }

void loop() { //read the three analog input pins and store their value to the color variables redVal = analogRead(redPot); greenVal = analogRead(greenPot); blueVal = analogRead(bluePot);

//use the map() function to scale the 10 bit (0-1023) analog input value to an 8 bit //(0-255) PWM, or analogWrite() signal. Then store the new mapped value back in the //color variable

redVal = map(redVal, 0, 1023, 0, 255); greenVal = map(greenVal, 0, 1023, 0, 255); blueVal = map(blueVal, 0, 1023, 0, 255);

// use the analogWrite() function to write the color values to their respective // RGB pins. analogWrite(redPin, redVal); analogWrite(greenPin, greenVal); analogWrite(bluePin, blueVal); }

Step 4: Demo

Different temperature ranges will produce a different colour LED. Blue is used for very cold indoor temperatures, indicated for temperatures below 16 degrees, followed by cyan, green, yellow, pink/purple, then red for searing hot temperatures. When I touch the temperature sensor the colour changes to purple or red, depending on my body temperature.

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

Invention Challenge 2017

Participated in the
Invention Challenge 2017

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge



    Question 4 years ago

    I wasn't able to get the code working, is there a link that I can have access to the whole code? Thanks


    Answer 2 years ago

    Hello nradnia; Maybe I can help; I've made a similar project. What part are you having problems with?