RGB Thermometer

Introduction: RGB Thermometer

I decided to make RGB themometer, which change color of RGB led depend on temperature. Circuit is simple and is good for practicing if conditions and bitwise operator.

I use this algorithm:

Measure temperature of room ->

if temperature is above 30 °C -> red color

if temperature is in range (27,30> -> yellow color

if temperature is in range (23,27> -> green color

if temperature is in range (18,23> -> cyan color

if temperature is less then 18 -> blue color

Step 1: BOM

You will need:

1. Arduino Uno or any (if you will use 3.3 V logic, then connect VCC pins to 3,3 V on Arduino), cables, breadboard

2. RGB led diode - I use with common anode (you must check it at buying if it is RGB with common cathode or cathode)

3.3x 220 ohm resistors

4. TMP36 temperature sensor

Step 2: Wiring

Wiring is simple, you will need to:

1. connect TMP 36. Left pin is Vcc, right pin is GND. I try to connect reversed, Arduino still live, but it will started to heat. Middle pin is signal, so connect it to any analog pin (must change in code then).

2. connect RGB led diode. I use RGB with common cathode, so I connect longest pin to GND. If you use RGB with common anode, then longest pin must connect to VCC (3.3 or 5V logic).

Also, if you connect to different pwm pins, you will get different colors, so you must match pins on rgb led with pins on arduino:

Right pin to PWM 11, left pin to PWM 9 and middle to PWM 10 (check picture). Very imporant, use 220 ohm resistors in serial! Otherwise, your arduino will damage due to shorted pins.

Step 3: Code

float voltage=0;
float analog=0;
float temp=0;

int red_light_pin= 11;
int green_light_pin = 10;
int blue_light_pin = 9;

//time delay
int _time=1000;

void setup(void)
pinMode(red_light_pin, OUTPUT);
pinMode(green_light_pin, OUTPUT);
pinMode(blue_light_pin, OUTPUT);

void loop(void) {

voltage = analog/1023;
temp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree with 500 mV offset

if (temp>30) {
// red
RGB_color(50, 0,0 );
else if (temp>27 & temp<=30) {
// yellow
RGB_color(50, 50,0 );
else if (temp>23 & temp<=27) {
// greem
RGB_color(0, 50,0 );
else if (temp>18 & temp<=23) {
// cyan
RGB_color(0, 25,25 );
else if (temp<=18) {
// blue
RGB_color(0, 0,25 );

else {
// white
RGB_color(50, 50,50 );


void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
analogWrite(red_light_pin, red_light_value);
analogWrite(green_light_pin, green_light_value);
analogWrite(blue_light_pin, blue_light_value);
Arduino Contest

Participated in the
Arduino Contest

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Robots Contest

      Robots Contest