Temperature Changing Color Cube




Introduction: Temperature Changing Color Cube

About: Hi! I make stuff. Sometimes I write instructions about them.

Recently I made a camera stand so I can film my hands while soldering and assembling my project (Instructable of this is coming soon). This is a kick-off project to test the equipment! (And I made it a gift for Henk Rijckaert)

It's a 6cm x 6cm x 6cm cube that changes colors based on the temperature!

Step 1: Parts Needed

You'll need the following:
- TMP36 temperature sensor
- RGB led, I used common anode, but can common cathode can be used with a small change
- ATTiny85
- 8 pin DIP socket
- LM1117t 3.3V linear voltage regulator
- 2x 50 ohm resistors
- 10 µF capacitor
- Perfboard
- 4xAAA battery holder (not in the picture)

To assemble the case I've used a laser cutter with one sheet of 30x60cm 3mm MDF and one sheet of 30x60cm 3mm plexi. You don't need the whole sheet, but I had it lying around. Some plexi cement is also needed for making the cube.

For programming the ATTiny85 you either need an Arduino, which is what I used, or a specific ATTiny85 programmer board.

To assemble the electronics you'll need a soldering iron and I've used a glue gun to afix the perfboard to the MDF.

Step 2: Making the Cube

The base is a simple vector graphic that can be cut using a laser cutter or be made by hand. It is slightly elevated to fit the battery holder. The perfboard is later hot glued to the rails.

The plexi planes are also cut with the laser cutter, but at the same time made diffuse by making tiny scratches with the laser. You can also buy diffused plexi, but that wasn't available to me.

The laser cutter uses a value between black (0) and white (255) to denote the intensity of the scratching. In order to see which value fitted best with the project I printed a test plane with every value.

Plexi cement was then used to fit the pieces together. To make it easier, I made a small mould from some scrap wood to hold it together.

Step 3: Soldering the Board

The wiring is quite straightforward, there's a picture of the scematic and of the layout on the perfboard. When you're done, you can attach the perfboard to the base with some hot glue.

Some handy pinout diagrams:

- ATtiny85
- TMP36
- LM1117t

Step 4: Coding

I've used my Arduino nano to flash the ATtiny85 chip. This guide helped in creating the board. You can also use a specific ATtiny85 programmer board.

The temperature isn't sensed continuously in order to save battery life. The sleep mode on the ATtiny85 is used to minimize its power consumption. The code is based on the work by Matthew Little on the website re-innovation.co.uk. Source

The temperature can be set to your liking, default it is set to switch at 18°C

The code is listed below or it can be downloaded in attachment.

#include <avr/sleep.h>;
#include <avr/wdt.h>;
// Routines to set and clear bits (used in the sleep code)
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
volatile boolean f_wdt = 1;
const int redPin = 1;
const int bluePin = 0;
const int sensorPin = 2;
const int fadeTime = 10;
// blue = 0, red = 1
int currentColor = 0;

void setup()
  pinMode(redPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  digitalWrite(bluePin, HIGH);
  digitalWrite(redPin, LOW);
void loop()
  if (f_wdt==1) {  // wait for timed out watchdog / flag is set when a watchdog timeout occurs
    f_wdt=0;       // reset flag
    system_sleep();  // Send the unit to sleep

void checkTemp()
    int reading = analogRead(sensorPin);  
    float voltage = reading * 3.3;
    voltage /= 1024.0;
    float temperatureC = (voltage - 0.5) * 100 ;
    if(temperatureC > 18) {
        if(currentColor != 1) {
        currentColor = 1;
    } else if(currentColor != 0) {
        currentColor = 0;

void fadeToRed(){
  int redVal = 255;
  int blueVal = 0;
  for( int i = 0 ; i < 255 ; i += 1 ){
    blueVal += 1;
    redVal -= 1;
    analogWrite( bluePin, 255 - blueVal );
    analogWrite( redPin, 255 - redVal );
    delay( fadeTime );

void fadeToBlue(){
  int redVal = 0;
  int blueVal = 255;
  for( int i = 0 ; i < 255 ; i += 1 ){
    blueVal -= 1;
    redVal += 1;
    analogWrite( bluePin, 255 - blueVal );
    analogWrite( redPin, 255 - redVal );
    delay( fadeTime );

// set system into the sleep state 
// system wakes up when watchdog is timed out
void system_sleep() {
  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF</p><p>  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
  sleep_enable();</p><p>  sleep_mode();                        // System actually sleeps here</p><p>  sleep_disable();                     // System continues execution here when watchdog timed out 
  sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON

// <a href="http://www.re-innovation.co.uk/web12/index.php/en/blog-75/306-sleep-modes-on-attiny85" rel="nofollow"> http://www.re-innovation.co.uk/web12/index.php/en...</a>
// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
void setup_watchdog(int ii) {
  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<wdce);
  MCUSR &= ~(1<<wdrf);

  // start timed sequence
  wdtcr |= (1<<WDCE) | (1<<WDE);
  // set a new watchdog timeout value
  WDTCR = bb;

Step 5: Enjoy!

If you followed every step correctly, then you should now have a cube in your possession that can sens the temperature!

Now what are the usecases?

One I found is that you now have indisputable proof for your girlfriend to say that the room is hot enough.

Ok, maybe there are no usecases. Still fun to make though!

Sensors Contest 2017

Runner Up in the
Sensors Contest 2017



    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest
    • Fix It! Contest

      Fix It! Contest

    15 Discussions

    I have a few questions, mainly regarding the components you used really as I'd love to give this build a go myself.

    I'm having issues finding 10µF capacitors - when I look for these online, I can only seem to find 10pF or 10nF capacitors that look like the ones you used. The 10µF ones seem to be a lot larger so I wanted to know if this was correct (sorry if this is a noob question)? Or would something like this be ok: http://uk.rs-online.com/web/p/aluminium-capacitors/6842068/

    The same applies to the resistors - I can only seem to find 47 or 56 ohm resistors. I would opt for the 47 ohm resistors myself, but I just wanted to check.

    Hope you can help.

    4 replies

    Sure! I'd love to help.
    First off, the capacitor. The voltage of AAA batteries changes depending how much it is drained. These are each roughly 1.5V and connected in series. When they are full they roughly give 4x1.5= 6V. When completely drained, it can even drop to 1V each, so it only delivers 4x1=4V.

    The ATtiny85 operates between 2.7 V and 5.5 V according to its specs. Here I use the LM1117t 3.3V linear voltage regulator to give a stable 3.3V output, which is in the operating voltage of the ATtiny. In the datasheet of the LM1117t they say this:

    "A minimum of 10-μF tantalum capacitor is required at the output to improve the transient response and stability"

    I looked around on your website and if you go into the "tantalum capacitor" category, you can filter on 10-μF. Then select one whose maximum voltage is higher than 3.3V.

    A resistor is needed for the LED to ensure that slight differences in voltage have only a minor effect on the LED's current. If you use higher values, then the LED will only shine a tiny tad dimmer. If you want to calculate the exact resistance, you can use Ohm's law. That is V = I x R. Here V is our supply voltage minus the drop voltage of the led (probably 2.2V), so V = 1.1V.

    I is how much the LED consumes, which is typically 20mA. In our formula you can bring over the I to the other side to make V / I = R.

    When you then plug in the numbers, 1.1 / 0.020 = 55, you get 55 ohms. Anything close to that number is good enough, so either the 47 or 56 ohm resistor is good.

    I hope that helps!

    Ok, so I have all the parts and I have assembled it. However, my LED stays blue no matter what, so I'm a little confused. I don't suppose you have a clearer fritzing diagram at all by any chance?

    Sorry, I was away for a while.

    The code can be buggy. I suggest that you try to pinpoint the problem by individually trying the outputs of the attiny.

    Something like this:
    const int redPin = 1;

    const int bluePin = 0;

    void setup()


    pinMode(redPin, OUTPUT);

    pinMode(bluePin, OUTPUT);


    void loop()


    digitalWrite(bluePin, HIGH);

    digitalWrite(redPin, LOW);

    delay( 500 );

    digitalWrite(bluePin, HIGH);

    digitalWrite(redPin, LOW);


    Fantastic! This is exactly the answer I needed, and I really appreciate you taking the time doing just this.

    That really helps me - I now thing I have everything I need to attempt it myself.


    Neat! all you need is a fridge with a transparent door now :)

    Love this. I can already see a use case that is ideal for my situation - telling colleagues whether it is warm enough in the office and to avoid the air-conditioning wars that inevtiably happen!

    Dr H

    1 year ago

    Simple and effective! I love it.

    Would there be an option to add two potentiometers, to simplify the setting of the upper and lower thresholds of the moderate range?

    I may try to implement something like that in my own thermometer constructs.
    Have a look.

    1 reply

    Yes, there are enough inputs left on the attiny. Here I did it with code so I can define an exact temperature in degrees .

    Great instructable.
    We can use it to test whether it is safe to touch or not for those things that get hot.
    Also for the heatsinks that we use in our circuits.

    1 reply

    It's also relatively inexpensive to make, the total components price was only a few euros.

    What a cool project. One use case I can think of is for my daughter, she is a little over a year and doesn't quite understand how a radiator heats up and cools down. Maybe something like this would be an obvious indicator... red is hot: do not touch. blue is cool: it's ok to touch. Lots of slay applications for this, thanks and well done!

    1 reply