for some reason the LEDS wont light up. i’ve quadruple checked all the connections/power/resistors/etc as well as the code but i cant figure it out. im getting readings but no no light. i’ve lowered the basline temp from 20 to 10 but it didn’t help
const int sensorPin = A0;
const float baselineTemp = 10;
void setup(){
Serial.begin(9600) // bits per second/ open serial port
;for(int pinNumber = 2; pinNumber<5; pinNumber++){
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, LOW);
}
}
void loop(){
int sensorval = analogRead(sensorPin);
Serial.print (" Sensor Value");
Serial.print ( sensorval);
float voltage = (sensorval/1024.0)*5.0;
Serial.print("Volts");
Serial.print(voltage);
Serial.print("Degrees C"); // convert voltage to temp C
float temperature = (voltage - 5) * 100;
Serial.println(temperature);
if(temperature < baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if (temperature >=baselineTemp +2 && temperature > baselineTemp+4){
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if (temperature >= baselineTemp +4 && temperature < baselineTemp +6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}else if (temperature >= baselineTemp +6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(1);
}
Are we supposed to know how your circuit is wired and every component and value ?
Try posting a schematic and photo of your setup. Have you tried running a led test program that only drives the leds first ?
UPDATE when i connect power the last LED lights up for a couple seconds and the temp sensor gets really hot.
I'm still trying to upload a picture somehow.
I can't see anything wrong with your connections. Might you have wired it up incorrectly earlier? Maybe you damaged the temp sensor. Do you have a pot (potentiometer)? You could wire that up in its place to test.
What are those resistors? Code looks like red-red-purple, which would be too high. But that might just be the camera. Red-Red-Brown (220R) would be fine.
When i hook up the potentiometer, all the lights come on. when i remove it, all the lights are still on. the resistors im using are red-red-brown. i tried a new temp sensor, but it's the same result. all the lights come on for a couple secs, then got off. And the sensor heats up like a stove.
i've tried both 5v and 3.3v. i actually solved the issue of it being to hot to touch by making the right pin of the sensor go to ground and the left to power. it's positioned with the round side facing away from arduino. What i've noticed is putting my fingers on the sensor doesn't increase the temperature. When i give it power, the temperature rapidly falls until 34.47C then doesn't go up if i press my fingers around it.
Hi, looking at the picture of your project, you have all the led and sensor gnds connected together but not connected to the arduino gnd.
That will fix quite a few problems.
I can see the red +5V wire but I can't see a ground wire connected to the arduino. Where is it ?
Also, I ran your code and I am measuring the temperature just fine. (after I made some changes).
I'd like to know how you can read the temperature with no delays after your print statements at 9600 bps .
Hi, you supplied the sensor data sheet, NOW which sensor is it?
Have you tried a 0.1uF Cap between the output pin of the sensor and it gnd pin, the device could be oscillating.
Tom…
Can you just write a simple sketch that turns the LEDs on and off, forget the sensor remove it.
See if the LEDs are working reliably, also when you refit the sensor , move it to another part of the protoboard incase you have a short under the board.