I'm new to Arduino so im still getting used to it...ineed to read the temperature of temperature sensor in arduino. Whatever i do, it keeps displaying same temperature(don't even know if that's wrong, but i think the temperature should be changing) over and over again. Dunno what i've done wrong, but here is my code anyway...
int senzor = 0;
int ldr = 0;
int ldr_vrednost = 0;
int ldr_sensitivity = 500;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
int vrednost = analogRead(senzor);
float napetost = (vrednost) * (5.0/1024.0);
float temperatura = (napetost - 0.5) * 100;
Serial.print("Stopinj C: "); Serial.print(temperatura);
Serial.println();
int vrednost_ldr = analogRead(ldr);
Serial.print("Svetlobni senzor: "); Serial.print(vrednost_ldr);
Serial.println();
if (vrednost_ldr < ldr_sensitivity)
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
delay(2000);
}
And the connection...
Result:
Any help will be appreciated!