So I found it feasible to make a thermometer in this heat seeing as I never know what the temperature is.
In this project, I'm using an Arduino Uno, RGB LED (picture below), and a TMP36. If something else comes to mind I might add it in.
Old versions:
Newest Code:
Code:
int temperaturePin = 0;
const int RED_LED_PIN = 9;
const int GREEN_LED_PIN = 10;
const int BLUE_LED_PIN = 11;
int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;
void setup()
{
Serial.begin(9600);
}
void loop() {
float temperature = getVoltage(temperaturePin);
// 9/5 (C+32
temperature = (temperature - .5) * 100/*)* 1.8) + 32*/;
float temperature2 = (9/5*(temperature +32));
Serial.println(temperature2); //printing the result
delay(1000);
if (temperature2 >= 89.99){
blueIntensity = 15;
greenIntensity = 10;
redIntensity = temperature2 +15;
}
else {
if (temperature2 >= 79.99){
greenIntensity = temperature2 /3+20;
redIntensity = 0;
blueIntensity = 0;
}
else {
if (temperature2 >= 69.99){
greenIntensity = 5;
blueIntensity = temperature2 /2;
redIntensity = 0;
}
else {
// we know temperature2 must be <= 69.98 if it gets to here
greenIntensity = 63;
redIntensity = 50;
blueIntensity = 100;
}
}
}
redIntensity = constrain(redIntensity, 0, 255);
greenIntensity = constrain(greenIntensity, 0, 255);
blueIntensity = constrain(blueIntensity, 0, 255);
analogWrite(RED_LED_PIN, redIntensity);
analogWrite(BLUE_LED_PIN, blueIntensity);
analogWrite(GREEN_LED_PIN, greenIntensity);
} // end of loop()
float getVoltage(int pin){
return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range
// to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}
[Code Updated!]
I will be updating this thread as I go, making further advancements, and most likely asking for help with small snippits of my code
Update 1:
Going to add support for the RGB LED (Link is just a picture)
What it is planned to do:
Change Red Green or blue values accordingly to the temperature.
Progress: ||||||||||about 87%
Needs to be done:
Better color display.
Improved temperature display.
Problems so far:
Cannot get the temperature to display only when there is a drastic change (i.e when it goes up or down by 1 degree.)
Cannot get the Diodes within the LED to light up accordingly. Blue/Green stay on even though at 90+ they are supposed to shut of (see code above). Red is always on as well. It produces a milky white color mos of the time (all 3 diodes are on.)