Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the LM35 or TMP36 sensor in Arduino projects?
They are temperature sensors that provide an analog voltage output proportional to the temperature, allowing Arduino to read and measure temperature.
Click to reveal answer
beginner
How do you convert the analog reading from an LM35 sensor to temperature in Celsius?
Read the analog value (0-1023), convert it to voltage (0-5V), then multiply by 100 because LM35 outputs 10mV per °C. Formula: temperature = (analogValue * 5.0 / 1023) * 100
Click to reveal answer
intermediate
What is the difference in output voltage between LM35 and TMP36 sensors?
LM35 outputs 0V at 0°C and 10mV per °C increase. TMP36 outputs 0.75V at 25°C and 10mV per °C increase, so TMP36 has an offset voltage of 0.5V at 0°C.
Click to reveal answer
beginner
Write the Arduino code line to read the analog value from a temperature sensor connected to analog pin A0.
int sensorValue = analogRead(A0);
Click to reveal answer
intermediate
How do you adjust the formula to convert TMP36 sensor readings to Celsius?
First convert analog reading to voltage, then subtract 0.5V offset, then multiply by 100. Formula: temperature = ((analogValue * 5.0 / 1023) - 0.5) * 100
Click to reveal answer
What does the analogRead() function return when reading a temperature sensor on Arduino?
ATemperature in Celsius directly
BA value between 0 and 1023 representing voltage level
CVoltage in volts
DDigital HIGH or LOW
✗ Incorrect
analogRead() returns a number from 0 to 1023 representing the voltage level on the analog pin.
Which sensor outputs 0.5V at 0°C as a baseline voltage?
ANeither LM35 nor TMP36
BLM35
CBoth LM35 and TMP36
DTMP36
✗ Incorrect
TMP36 outputs 0.5V at 0°C, while LM35 outputs 0V at 0°C.
If analogRead(A0) returns 512, what is the approximate voltage on the pin (assuming 5V reference)?
A2.5V
B5V
C1V
D0.5V
✗ Incorrect
Voltage = (512 / 1023) * 5V ≈ 2.5V
How do you calculate temperature from LM35 sensor reading?
AMultiply voltage by 100
BSubtract 0.5V then multiply by 100
CDivide voltage by 10
DAdd 0.5V then multiply by 10
✗ Incorrect
LM35 outputs 10mV per °C with 0V at 0°C, so temperature = voltage * 100.
Which Arduino function reads analog voltage from a sensor?
AdigitalRead()
BanalogWrite()
CanalogRead()
DdigitalWrite()
✗ Incorrect
analogRead() reads analog voltage levels from pins.
Explain how to read temperature from an LM35 sensor using Arduino, including the formula to convert the analog reading to Celsius.
Think about how the sensor voltage relates to temperature and how Arduino reads voltage.
You got /4 concepts.
Describe the difference in output voltage behavior between LM35 and TMP36 sensors and how that affects temperature calculation.
Focus on the baseline voltage each sensor outputs at zero degrees Celsius.
You got /4 concepts.
Practice
(1/5)
1. What does the analogRead() function do when reading from an LM35 temperature sensor?
easy
A. It sets the sensor's output voltage to a fixed value.
B. It converts the temperature directly to Celsius.
C. It sends data to the sensor to start measuring temperature.
D. It reads the voltage level from the sensor's analog output pin.
Solution
Step 1: Understand analogRead() function
The analogRead() function reads the voltage level on an analog pin and returns a number between 0 and 1023 representing that voltage.
Step 2: Relate to LM35 sensor output
The LM35 outputs an analog voltage proportional to temperature, so analogRead() reads this voltage level.
Final Answer:
It reads the voltage level from the sensor's analog output pin. -> Option D
Quick Check:
analogRead() reads voltage level = A [OK]
Hint: Remember: analogRead() reads voltage, not temperature directly [OK]
Common Mistakes:
Thinking analogRead() converts voltage to temperature
Assuming analogRead() sends commands to sensor
Confusing analogRead() with digitalRead()
2. Which of the following is the correct way to convert the analog reading from an LM35 sensor to voltage in Arduino code?
easy
A. float voltage = analogRead(sensorPin) / 5.0;
B. float voltage = analogRead(sensorPin) * 1023.0 / 5.0;
C. float voltage = analogRead(sensorPin) * (5.0 / 1023.0);
D. float voltage = analogRead(sensorPin) * 5.0;
Solution
Step 1: Understand analog to voltage conversion
The analog reading ranges from 0 to 1023 for 0 to 5 volts. To get voltage, multiply reading by (5.0 / 1023.0).
Step 2: Check each option
float voltage = analogRead(sensorPin) * (5.0 / 1023.0); correctly applies the formula. Others either divide incorrectly or multiply by wrong factors.
Final Answer:
float voltage = analogRead(sensorPin) * (5.0 / 1023.0); -> Option C
Quick Check:
Voltage = reading * (5/1023) [OK]
Hint: Use (5.0 / 1023.0) to convert analog reading to voltage [OK]
Common Mistakes:
Dividing by 5 instead of multiplying
Using 1024 instead of 1023 in denominator
Multiplying by 5 without dividing by 1023
3. What will be the output on the Serial Monitor if the following Arduino code reads an analog value of 250 from an LM35 sensor?
int sensorPin = A0;
int reading = 250;
float voltage = reading * (5.0 / 1023.0);
float temperatureC = voltage * 100;
Serial.println(temperatureC);
medium
A. 122.0
B. 12.2
C. 0.25
D. 1.22
Solution
Step 1: Calculate voltage from reading
voltage = 250 * (5.0 / 1023.0) ≈ 1.22 volts.
Step 2: Calculate temperature in Celsius
temperatureC = 1.22 * 100 ≈ 122 °C. Serial.println displays approximately 122.19, closest to 122.0.
Final Answer:
122.0 -> Option A
Quick Check:
Voltage ≈1.22V, Temp = voltage*100 = 122 [OK]
Hint: Multiply voltage by 100 to get Celsius for LM35 [OK]
Common Mistakes:
Forgetting to multiply voltage by 100
Using wrong analog to voltage conversion
Confusing TMP36 formula with LM35
4. Identify the error in this Arduino code snippet for reading TMP36 temperature sensor:
int sensorPin = A0;
int reading = analogRead(sensorPin);
float voltage = reading / 1023 * 5.0;
float temperatureC = (voltage - 0.5) * 100;
Serial.println(temperatureC);
medium
A. The voltage calculation divides before multiplying, causing integer division error.
B. The sensorPin should be declared as float, not int.
C. The temperature formula is incorrect for TMP36 sensor.
D. Serial.println() cannot print float values.
Solution
Step 1: Analyze voltage calculation
reading / 1023 * 5.0 uses left-to-right precedence: first reading / 1023 (int / int = integer division, truncates), then * 5.0, yielding wrong voltage.
Step 2: Rule out other options
A: Formula (voltage - 0.5)*100 correct for TMP36. B: Pin declaration int is fine. D: Serial.println prints floats fine.
Final Answer:
The voltage calculation divides before multiplying, causing integer division error. -> Option A
Quick Check:
Use float divisor to avoid integer division [OK]
Hint: Use float numbers in division to avoid integer division [OK]
Common Mistakes:
Using integer 1023 instead of float 1023.0
Misunderstanding operator precedence
Thinking Serial.println() can't print floats
5. You want to read temperature from a TMP36 sensor connected to analog pin A1 and print the temperature in Celsius every second. Which Arduino code snippet correctly implements this?
hard
A. int sensorPin = A1;
void loop() {
int reading = analogRead(sensorPin);
float voltage = reading / 1023 * 5;
float temperatureC = voltage * 100;
Serial.println(temperatureC);
delay(1000);
}
B. int sensorPin = A1;
void loop() {
int reading = analogRead(sensorPin);
float voltage = reading * (5.0 / 1023.0);
float temperatureC = (voltage - 0.5) * 100;
Serial.println(temperatureC);
delay(1000);
}
C. int sensorPin = A1;
void loop() {
int reading = analogRead(sensorPin);
float voltage = reading * (5 / 1023);
float temperatureC = (voltage - 0.5) * 100;
Serial.println(temperatureC);
delay(1000);
}
D. int sensorPin = A1;
void loop() {
int reading = analogRead(sensorPin);
float voltage = reading * (5.0 / 1023.0);
float temperatureC = voltage * 100;
Serial.println(temperatureC);
delay(1000);
}