Hi everyone,
I am working on a small Arduino project where I want to control an LED based on readings from a temperature sensor.
I have written the code, but the LED is not responding as expected. I am using an Arduino Uno and a TMP36 sensor.
Can anyone guide me on what I might be doing wrong or suggest how to fix it? Any tips or sample code would be really appreciated!
As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming category of the forum
In order to provide help the members of the forum need more details
Please post your full sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
Please post a schematic of your project showing how each of the components of it are connected and powered. A 'photo of a hand drawn circuit diagram is good enough
To post images etc. you need trust level 1, you can get there by:
Entering at least 5 topics
Reading at least 30 posts
Spend a total of 10 minutes reading posts
Users at trust level 1 can...
Use all core Discourse functions; all new user restrictions are removed
The example shows how the TMP36 works, how to assemble the project, how to read the TMP36, and most importantly, how to interpret the output of the TMP36 (see the "output voltage versus temperature" graph).
convert the reading from A-to-D bits (0 to 1024) to voltage (0.1 to 2.0 - see Datasheet, Page 3)
convert the voltage to a temperature (−40°C ≤ TA ≤ +125°C - see Datasheet, Page 3)
print the measured/calculated temperature
Your Arduino IDE has "built-in" examples (FILE >> EXAMPLES >> BUILT-IN EXAMPLES at the top). These examples are also found on-line: https://docs.arduino.cc/built-in-examples/
Expand your Arduino programming by browsing the Arduino Language Reference. When you get stuck with programming, find this reference for "how to": https://docs.arduino.cc/language-reference/