Complete the code to read the analog value from the temperature sensor.
int sensorPin = A0;
int sensorValue = [1];
The analogRead() function reads the analog voltage from the sensor pin.
Complete the code to convert the analog value to voltage (assuming 5V reference).
float voltage = sensorValue * [1] / 1023.0;
The Arduino analog reference voltage is 5.0 volts, so multiply by 5.0 before dividing by 1023.
Fix the error in the code to calculate temperature in Celsius for LM35 sensor.
float temperatureC = voltage [1] 0.01;
The LM35 outputs 10mV (0.01V) per degree Celsius, so divide voltage by 0.01 to get temperature.
Fill both blanks to calculate temperature in Celsius for TMP36 sensor.
float temperatureC = (voltage [1] 0.5) [2] 0.01;
The TMP36 sensor outputs 0.5V at 0°C and 10mV/°C, so subtract 0.5V then divide by 0.01 to get Celsius.
Fill the blanks to print the temperature in Celsius with one decimal place.
Serial.print("Temperature: "); Serial.print([1], [2]); Serial.println(" C");
Use Serial.print() with the temperature variable and specify 1 decimal place for clarity.
