Project 3 - All LEDs lit up at once

EDIT - I've found a similar issue, going there instead:
https://forum.arduino.cc/index.php?topic=563258.0


Hi guys!

I am following the Starter Kit projects and I have stumbled across a problem on the Love-o-Meter. When I remove the end conditions to lit the LEDs, the temperature output is always right. If I uncomment the conditions and test, it seems the moment when it lits one LED, the voltage output of the temperature sensor changes drastically. All LEDs lit at once.

I am quite new in electronic, so maybe there something there I didn't quite understand (does lighting a LED affect the current passing by my temperature sensor? This is my hypothesis since the Sensor value never goes down to his reset value, since the LEDs stay lit.

I have attached a photo of my Uno and my code. Thanks!

sketch_exercice3.ino (1.21 KB)

COM4 (ArduinoGenuino Uno).png - Paint.jpg

Oh wow, I am so glad to have found your post! It describes almost exactly what is happening in my case.

For all three LEDs lighting up at once, you can adjust the if statement so the three temperature bands the LED lighting corresponds to is a little bit wider. That's what I had done, but all that it really does is that you see the LEDs light up in succession, but staying on from that point on.

For comparison here are my readings when the LED state controlling if statements is enabled, pretty much like the tutorial recommends:
18:10:39.992 -> Sensor value: 147, Volts: 0.72, degrees C: 21.78
18:10:41.881 -> Sensor value: 148, Volts: 0.72, degrees C: 22.27
18:10:43.876 -> Sensor value: 164, Volts: 0.80, degrees C: 30.08
18:10:45.871 -> Sensor value: 208, Volts: 1.02, degrees C: 51.56
18:10:47.879 -> Sensor value: 208, Volts: 1.02, degrees C: 51.56
18:10:49.900 -> Sensor value: 207, Volts: 1.01, degrees C: 51.07
18:10:51.894 -> Sensor value: 206, Volts: 1.01, degrees C: 50.59
18:10:53.903 -> Sensor value: 206, Volts: 1.01, degrees C: 50.59
18:10:55.881 -> Sensor value: 206, Volts: 1.01, degrees C: 50.59
18:10:57.898 -> Sensor value: 206, Volts: 1.01, degrees C: 50.59
18:10:59.914 -> Sensor value: 205, Volts: 1.00, degrees C: 50.10
18:11:01.890 -> Sensor value: 205, Volts: 1.00, degrees C: 50.10
18:11:03.919 -> Sensor value: 205, Volts: 1.00, degrees C: 50.10
18:11:05.906 -> Sensor value: 204, Volts: 1.00, degrees C: 49.61
18:11:07.899 -> Sensor value: 205, Volts: 1.00, degrees C: 50.10
18:11:09.921 -> Sensor value: 204, Volts: 1.00, degrees C: 49.61
18:11:11.911 -> Sensor value: 204, Volts: 1.00, degrees C: 49.61
18:11:13.899 -> Sensor value: 204, Volts: 1.00, degrees C: 49.61
18:11:15.909 -> Sensor value: 204, Volts: 1.00, degrees C: 49.61
18:11:17.932 -> Sensor value: 203, Volts: 0.99, degrees C: 49.12
18:11:19.940 -> Sensor value: 203, Volts: 0.99, degrees C: 49.12

Now, same exact setup, but with the if statement commented out:
18:06:22.206 -> Sensor value: 147, Volts: 0.72, degrees C: 21.78
18:06:24.223 -> Sensor value: 147, Volts: 0.72, degrees C: 21.78
18:06:26.205 -> Sensor value: 147, Volts: 0.72, degrees C: 21.78
18:06:28.230 -> Sensor value: 147, Volts: 0.72, degrees C: 21.78
18:06:30.226 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:06:32.200 -> Sensor value: 154, Volts: 0.75, degrees C: 25.20
18:06:34.233 -> Sensor value: 155, Volts: 0.76, degrees C: 25.68
18:06:36.230 -> Sensor value: 154, Volts: 0.75, degrees C: 25.20
18:06:38.237 -> Sensor value: 154, Volts: 0.75, degrees C: 25.20
18:06:40.209 -> Sensor value: 153, Volts: 0.75, degrees C: 24.71
18:06:42.240 -> Sensor value: 153, Volts: 0.75, degrees C: 24.71
18:06:44.215 -> Sensor value: 152, Volts: 0.74, degrees C: 24.22
18:06:46.222 -> Sensor value: 151, Volts: 0.74, degrees C: 23.73
18:06:48.247 -> Sensor value: 151, Volts: 0.74, degrees C: 23.73
18:06:50.255 -> Sensor value: 151, Volts: 0.74, degrees C: 23.73
18:06:52.232 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:06:54.244 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:06:56.241 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:06:58.260 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:07:00.235 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:07:02.249 -> Sensor value: 150, Volts: 0.73, degrees C: 23.24
18:07:04.256 -> Sensor value: 149, Volts: 0.73, degrees C: 22.75
18:07:06.266 -> Sensor value: 149, Volts: 0.73, degrees C: 22.75
18:07:08.249 -> Sensor value: 149, Volts: 0.73, degrees C: 22.75
18:07:10.266 -> Sensor value: 149, Volts: 0.73, degrees C: 22.75

In both of these examples I turned the circuit on, then placed my finger on the TMP36 sensor for a second or two, then removed it. You can see that in my case too, the temperature readings never go back down when the if statement is uncommented.

I have a support case open with Arduino on this issue that is still being looked at. Some of my coworkers with Arduino experience suggested using capacitors to mitigate the noise the LEDs might be introducing.

Attaching the temperature sensor to the other power bus fixes this problem.
So it was because they were attached to the same GND.

I had the same issue. I was able to fix it by putting a 10k resistor between the power and the Vs of the sensor.

urketadic's solution also works.

It's kind of annoying and frustrating to fail like this in the third project. I'm reading the projects from the starter kit book. Will be nice to see the updated schema and some explanation for beginners. Why is this happening?

Have a nice Arduino-ing! :slight_smile:

I found it much easier to simply tweak the temperature requirements of the if loop. Here is my code:

if(temperature < baselineTemp+7){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+7 && temperature < baselineTemp+8){
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+8 && temperature < baselineTemp+9){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+9){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);

This seems to work best for me. LEDs respond quickly when I touch the sensor and increment back to LOW a bit more slowly but quickly enough.

indeed, tweaking the sketch was much easyer and also gives the right data in the serial link on the PC