I'm making a device that senses temperature below a certain level and then turns a red LED if the temperature is below that level. There is a screenshot of my virtual model on TinkerCad in this post.
If I want to I want to turn on the LED IF the temperature sensor senses temperature below the level. How do I write this in the code? Sorry if this is a simple question , I am new to electronics.
What type of temperature sensor do you have? It will probably need a resistor, and maybe also an opamp.It must be connected to an analog input pin (A0 .. A5).
The led must have a series resistor, with a value of 470 .. 1000 ohm, and be connected between a GPIO pin (2 .. 12) and GND.
The code is simple:
if (temp < 18)
 {
  digitalWrite(ledPin, HIGH);
 }
 else
 {
  digitalWrite(ledPin, LOW);
 }
But I think you should first experiment with some of the example sketches in the IDE, to get some understanding of the programming code for an Arduino.
Erik_Baas:
But I think you should first experiment with some of the example sketches in the IDE, to get some understanding of the programming code for an Arduino.
You will not be able to finish this project if you don't know how to program an Arduino. We can help you if there is a problem, but you must do (most of) it yourself.