Hi I have Arduino Uno and I wrote a typical code to get temperature measurements using a thermistor. I am using the Steinhart-Hart Method from this site: http://garagelab.com/profiles/blogs/tutorial-using-ntc-thermistors-with-arduino.
my only difference is that I used 15k thermistor and 15k resistor in the circuit.
Here is the code
#include <Thermistor.h>
Thermistor temp(0);
int R1 = 12; //R1 sundemenh sto pin 12
int R2 = 11; //R2 sundemenh sto pin 11
int R3 = 10; //R3 sundemenh sto pin 10
int val; //metablith gia to diabasma tis thermokrasias
void setup()
{
Serial.begin(9600);
pinMode(R1, OUTPUT); //Orise tin R1 ws eksodo
pinMode(R2, OUTPUT); //Orise tin R2 ws eksodo
pinMode(R3, OUTPUT); //Orise tin R3 ws eksodo
digitalWrite(R1, HIGH); //Energopoihse thn antistash R1
digitalWrite(R2, HIGH); //Energopoihse thn antistash R2
digitalWrite(R3, HIGH); //Energopoihse thn antistash R3
}
void loop()
{
int temperature = temp.getTemp();
Serial.print("H thermokrasia nerou einai: ");
Serial.print(temperature);
Serial.println("*C");
val = digitalRead(temperature); //Diavase tin thermokrasia kai apothikeuse thn stin val
if (val > 27) //Ean h thermokrasia megaluterh h ish me 27C
{
digitalWrite(R1, LOW); //klise tin R1
}
if (val > 30) //Ean h thermokrasia megaluterh h ish me 30C
{
digitalWrite(R2, LOW); //klise tin R2
}
if (val > 33) //Ean h thermokrasia megaluterh h ish me 33C
{
digitalWrite(R3, LOW); //klise tin R3
}
delay(6000); //perimene 6 deuterolepto
}
The R1, R2 and R3 are the names of my LEDS...
In the serial monitor I get the values of the temperatures perfectly but when the temperature comes to 27,30 and 31 degrees of celsius the leds suppose to be in LOW contition, that is not happening!
Any ideas why?