This instructable will show you how to code an Arduino Uno board to power on a strand of lights depending on temperature using a 9 volt battery! The pictures included show how i attached mine to a mechanic jumpsuit to wear to parties!

Step 1: The Materials

First of all, you're going to need a mechanic suit to work with! I was able to purchase mine from Amazon cheaply and easily. If you don't want to use a mechanic's jumpsuit, that's okay! This project will work well with whatever you decide to wear or attach it to!

The tech you'll need:

  • A TMP36 sensor
  • An Arduino Uno board
  • A 9-Volt power-attachment piece for the Arduino
  • A 9-Volt battery
  • Female-to-male solderless pin wire connector for Arduino
  • Individually addressable RBG LED Strip

Step 2: Creating the Board

Now, we want to attach the pieces onto the board. I've attached a picture to help the visual learners.

The TMP Sensor is going to be attached to the board with the flat face facing outwards away from the board. The left leg will be attached to the ground pin, and the right leg into the 3.3V pin. The middle pin will have a female-to-male pin attached, with the male side going into the A0 pin.

The LED strip's wires will be attaching to the Arduino as well. The green wire will be attaching to the A13 Pin, the ground wire (black) will be attaching to the second ground pin on the Arduino, and the power (red) wire will be attaching to the 5V pin on the Arduino.

Attach the 9-Volt connector to the Arduino as well.

Step 3: The Code

Using Arduino 1.8.1 (which can be downloaded from the internet), the following code needs to be uploaded to your board. It's long, so beware!

#define PIN 13

#define NUMLEDS 150


SparkFun Inventor's Kit Example sketch 07

const int temperaturePin = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMLEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup()

// In this sketch, we'll use the Arduino's serial port

// to send text back to the main computer. For both sides to

// communicate properly, they need to be set to the same speed.

// We use the Serial.begin() function to initialize the port

// and set the communications speed.

// The speed is measured in bits per second, also known as

// "baud rate". 9600 is a very commonly used baud rate,

// and will transfer about 10 characters per second.



strip.show(); }

void loop()

// Up to now we've only used integer ("int") values in our

// sketches. Integers are always whole numbers (0, 1, 23, etc.).

// In this sketch, we'll use floating-point values ("float").

// Floats can be fractional numbers such as 1.42, 2523.43121, etc.

// We'll declare three floating-point variables

// (We can declare multiple variables of the same type on one line:)

float voltage, degreesC, degreesF;

// First we'll measure the voltage at the analog pin. Normally

// we'd use analogRead(), which returns a number from 0 to 1023.

// Here we've written a function (further down) called

// getVoltage() that returns the true voltage (0 to 5 Volts)

// present on an analog input pin.

voltage = getVoltage(temperaturePin);

// Now we'll convert the voltage to degrees Celsius.

// This formula comes from the temperature sensor datasheet:

degreesC = (voltage - 0.5) * 100.0;

// While we're at it, let's convert degrees Celsius to Fahrenheit.

// This is the classic C to F conversion formula:

degreesF = degreesC * (9.0/5.0) + 32.0;

// Now we'll use the serial port to print these values

// to the serial monitor!

// To open the serial monitor window, upload your code,

// then click the "magnifying glass" button at the right edge

// of the Arduino IDE toolbar. The serial monitor window

// will open.

// (NOTE: remember we said that the communication speed

// must be the same on both sides. Ensure that the baud rate

// control at the bottom of the window is set to 9600. If it

// isn't, change it to 9600.)

// Also note that every time you upload a new sketch to the

// Arduino, the serial monitor window will close. It does this

// because the serial port is also used to upload code!

// When the upload is complete, you can re-open the serial

// monitor window.

// To send data from the Arduino to the serial monitor window,

// we use the Serial.print() function. You can print variables

// or text (within quotes).

Serial.print("voltage: ");


Serial.print(" deg C: ");


Serial.print(" deg F: ");


if (degreesF >= 81){



else {

colorWipe(strip.Color(0, 0, 0), 0); // Red
colorWipe(strip.Color(0, 0, 0), 0); // Green

colorWipe(strip.Color(0, 0, 0), 0); }

// These statements will print lines of data like this:

// "voltage: 0.73 deg C: 22.75 deg F: 72.96"

// Note that all of the above statements are "print", except

// for the last one, which is "println". "Print" will output

// text to the SAME LINE, similar to building a sentence
// out of words. "Println" will insert a "carriage return"
// character at the end of whatever it prints, moving down

// to the NEXT line.

delay(1000); // repeat once per second (change as you wish!) }

float getVoltage(int pin)

// This function has one input parameter, the analog pin number

// to read. You might notice that this function does not have

// "void" in front of it; this is because it returns a floating-

// point value, which is the true voltage on that pin (0 to 5V).

// You can write your own functions that take in parameters

// and return values. Here's how:

// To take in parameters, put their type and name in the

// parenthesis after the function name (see above). You can

// have multiple parameters, separated with commas.

// To return a value, put the type BEFORE the function name

// (see "float", above), and use a return() statement in your code

// to actually return the value (see below).

// If you don't need to get any parameters, you can just put

// "()" after the function name.

// If you don't need to return a value, just write "void" before

// the function name.

// Here's the return statement for this function. We're doing

// all the math we need to do within this statement:

return (analogRead(pin) * 0.004882814);

// This equation converts the 0 to 1023 value that analogRead()
// returns, into a 0.0 to 5.0 value that is the true voltage

// being read at that pin. }

// Other things to try with this code:

// Turn on an LED if the temperature is above or below a value.

// Read that threshold value from a potentiometer - now you've

// created a thermostat!

//Theatre-style crawling lights with rainbow effect

void theaterChaseRainbow(uint8_t wait) {

for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel

for (int q=0; q < 3; q++) {

for (uint16_t i=0; i < strip.numPixels(); i=i+3) {

strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on

} strip.show();


for (uint16_t i=0; i < strip.numPixels(); i=i+3) {

strip.setPixelColor(i+q, 0); //turn every third pixel off





void colorWipe(uint32_t c, uint8_t wait) {

for(uint16_t i=0; i<strip.numPixels(); i++) {

strip.setPixelColor(i, c);




// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.

uint32_t Wheel(byte WheelPos) {

WheelPos = 255 - WheelPos;

if(WheelPos < 85) {

return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);


if(WheelPos < 170) {

WheelPos -= 85;

return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);


WheelPos -= 170;

return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);


Step 4: What the Code Does

That particular code triggers 150 lights on your strand to go through a rainbow cycle, where every single light, starting from the first one and going until the last, cycles through every available color on its scheme as soon as the temperature sensor hits a temp reading of 81 degrees F or above. If the sensor reads anything below that, the lights will shut off.

Step 5: Combining Your Pieces!

This step, along with the rest of the steps, allow for personal freedom. Now that your code has been set, your Arduino is cycling through colors, and you have your clothing, it's time for you to attach the tech to your suit!

<p>That's a fun idea :)</p>

About This Instructable




More by ObiWanJacobi:Mechanic Party Suit 
Add instructable to: