I've designed this system which is supposed to turn on the LEDs when the temperature of a particular probe exceeds 32 degrees. From what I can tell, this should be functional but the analog sensor is always reading 0 when calling analogRead() on the pin.
Here is an image of my circuit:
and my code:
int length = 5;
float airTemp = 32;
void setup()
{
Serial.begin(9600);
}
void loop()
{
// loads current temperature into array
int reading;
float voltage;
float temp[length];
for (int i = 0; i < length; i++)
{
reading = analogRead(i);
Serial.print(reading);
voltage = reading * 5.0;
voltage /= 1024;
temp[i] = (voltage - 0.5) * 100;
}
// turns on/off fans based on current temperature
for (int i = 0; i < length; i++)
{
pinMode(i, OUTPUT);
if (temp[i] > airTemp)
{
digitalWrite(i + 8, HIGH);
}
else if(temp[i] <= airTemp)
{
digitalWrite(i + 8, LOW);
}
}
delay(1000);
}
I learned how to read the temperature from here. It's probably a dumb mistake, but I just started working with Arduino yesterday and I couldn't find information anywhere so thanks in advance.