Help needed with Arduino project – LED & sensor issue

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!

Thanks in advance.

Welcome to the forum

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
  • Send PMs
  • Upload images and attachments

Welcome to the Arduino forum. Can you be a bit more specific, since we do not know what you are expecting.

Once we can see the code and wiring diagram, someone may be able to help.

Or, just look here; Google can be wonderful!

Did not show the code

why not?

oops

2 Likes

Search "arduino LED" to find how to wire the LED to the Arduino, and how to turn the LED ON and turn the LED OFF. One example is this: https://docs.arduino.cc/built-in-examples/basics/Blink/

Search "tmp36" to find a datasheet to reference. Here is a link to the datasheet: https://www.makerguides.com/wp-content/uploads/2020/10/TMP35-TMP36-TMP37-datasheet.pdf

Search "arduino tmp36" where you will find many links (good and bad). Here is one that seems thorough... TMP36 Temperature Sensor Arduino Tutorial (2 Examples)

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).

The example will show a few steps for the code:

  • read the value of the TMP36
  • 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/