Tahani Almanie
Published

Temperature Necklace

A necklace that shows different light colors (red- green- blue) according to the current ambient temperature.

IntermediateFull instructions provided3,350
Temperature Necklace

Things used in this project

Hardware components

Lilypad Arduino Development Kit
SparkFun Lilypad Arduino Development Kit
×1
SparkFun Alligator Test Leads
×7
30AWG Wire Wrapping Colored
×1
SparkFun Wire Strippers
×1

Hand tools and fabrication machines

Necklace
thick chain
Felt
Needle-Threads-Scissors
Hot glue gun (generic)
Hot glue gun (generic)
Piece of paper

Story

Read more

Schematics

circuit diagram

Code

Temperature Necklace

Arduino
  /*
 * This program shows different light colors according to the current ambient temperature: 
 * It gives a green color to indicate the cool weather (68 to 78 degrees Fahrenheit). 
 * A red color is shown when the weather is relatively hot (above 78 degrees Fahrenheit) 
 * and a blue one to represent the cold weather (below 68 Fahrenheit).
 * 
 * Written by Tahani Almanie
 */

int tempSenPin = A2; // Temperature sensor connected to analog pin A2
int tempReading;    // This variable for the sensor reading
float voltage;      // This variable for the voltage value of the sensor
float tempC;         // This variable for the Centigrade temperature 
float tempF;         // This variable for the Fahrenheit temperature

int redPin = 9;     // R on RGB LED connected to digital pin 9
int greenPin = 11;  // G on RGB LED connected to digital pin 11 
int bluePin = 10;   // B on RGB LED connected to digital pin 10 

void setup() 
{
    Serial.begin(9600);  //Start the serial connection to view the sensor readings
}

void loop() 
{ 
   //getting the reading from the temperature sensor
   tempReading = analogRead(tempSenPin);

   // converting that reading to voltage
   voltage = tempReading * 4.15 / 1024.0;
   // print out the voltage
   Serial.print(voltage); Serial.println(" volts");
   
   // converting that voltage to Centigrade temperature
   tempC = (voltage - 0.5) * 100 ; 
   // print out the Centigrade temperature                                             
   Serial.print(tempC); Serial.println(" degrees C");
   
   // converting Centigrade to Fahrenheit
   tempF = (tempC * 9.0 / 5.0) + 32.0;
   // print out the Fahrenheit temperature
   Serial.print(tempF); Serial.println(" degrees F");

   //waiting 1 second
   delay(1000);

   lightColor();
}

void lightColor()   
{ 
         if (tempF >= 78 )              //hot ambient gives a red light 
            generateColor(255,0,0);       

         else if (tempF>=68 && tempF<78)//nice ambient gives a green light 
            generateColor(0,255,0);        

         else                           //cold ambient gives a blue light 
            generateColor(0,0,255);             
}  
 
void generateColor(int red, int green, int blue)
{  
         analogWrite(redPin, 255-red);   
         analogWrite(greenPin, 255-green);  
         analogWrite(bluePin, 255-blue);    
}

Credits

Tahani Almanie

Tahani Almanie

3 projects • 4 followers
Thanks to Leah Buechley and Lady ada.

Comments