fbpx

Coding for Temperature sensor


 


Steps to do coding in Tinkercad

1. Click the code editor button to open the coding panel.










 

We will code to read the temperature in CelsiusFahrenheit and if the temperature is greater than the threshold value then the Led’s will glow.

  1. First we will make a variable named as “temp” to store the value coming from the temperature sensor i.e connected to A0 pin of arduino.

  2. Then convert the temperature into Fahrenheit by using the formula and store it in the variable named as Fahrenheit.

  3.  Now, print temperature values in the serial monitor using print to serial block.

  4. Then put the condition that if the temperature is lesser than threshold value i.e. 50 then all the led will turn off and if then value is greater than 50 then all the led’s will glow.

Make the code as shown below: