Hey, so I have being trying to create a circuit that will have a colour displayed on the rgb in relation to the temperature detected. I have an rgb and a temperature set up in the form seen in the pictures below and am using the code that will put below. I have trialled the circuit on the TinkerCAD application with the same code and I'm pretty sure the same set up and it works there, but not in practice. I'm fairly new to using the Arduino. So if you spot any mistakes in my circuit or code any help would be appreciated.
Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
Can you read the temperature? (And "see it" with the serial monitor?)
Can you control the LEDs (just under software control without temperature or any other input)?
It's always best to "develop" your code and your project a little at a time. i.e. If you think you've got an LED problem, try a regular single-color LED or one-color (two connections) from the RGB LED and make a simple test-program (like the Blink Example) to try it out.
Usually from the datasheet. Or if it's not working you may have to change your wiring.
And... You may not have hardware/wiring problem but it's hard to figure-out a photo of your circuit. A schematic is much better. (The issue with a schematic is that it has to match the physical-actual wiring, but the first thing is to know if the circuit design is correct.
If an Uno (or 328 based), that will actually be translated by the analogRead() to multiplexer channel 0 or pin 14 (A0). See wiring_analog.c in the core files.
But using the Ax notation does make the code more clearly readable.
Hi thanks a lot for the help,
I've changed the code as you said but also changed the temperature pin to the a0 pin in the code, as that is what I had it set up like.
It is now producing a light, which wasn't happening before however when looking at the temperature's received, the average is around 107 degrees celcius, which is way too high. I found online that the conversion rate between voltage and celcius is (voltage - 0.5) * 100. Is this wrong?
Hi thanks,
Here is the most recent version of my code. Pretty sure the problem with the temperature has been fixed however now I don't seem to be getting changes in temperature when applying cold items to the temperature sensor