0
0
Embedded Cprogramming~10 mins

Sensor reading through ADC (temperature, light) in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start the ADC conversion.

Embedded C
ADC_StartConversion([1]);
Drag options to blanks, or click blank then click option'
AADC0
BADC2
CADC3
DADC1
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong ADC module like ADC1 or ADC2.
Forgetting to start the ADC conversion.
2fill in blank
medium

Complete the code to read the ADC value from the temperature sensor channel.

Embedded C
uint16_t tempValue = ADC_ReadChannel([1]);
Drag options to blanks, or click blank then click option'
A2
B3
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Reading from the wrong ADC channel.
Using an invalid channel number.
3fill in blank
hard

Fix the error in the code to convert ADC value to temperature in Celsius.

Embedded C
float temperatureC = ([1] * 330.0) / 1023.0;
Drag options to blanks, or click blank then click option'
AADC_Value
BtempValue
Cadc_reading
DsensorVal
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined variables like ADC_Value or adc_reading.
Forgetting to use the correct variable for conversion.
4fill in blank
hard

Fill both blanks to read light sensor value and convert it to voltage.

Embedded C
uint16_t lightRaw = ADC_ReadChannel([1]);
float lightVoltage = (lightRaw * [2]) / 1023.0;
Drag options to blanks, or click blank then click option'
A1
B3.3
C2
D5.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong ADC channel for light sensor.
Using incorrect reference voltage for conversion.
5fill in blank
hard

Fill all three blanks to create a dictionary mapping sensor names to their converted values.

Embedded C
float sensorValues[] = {temperatureC, lightVoltage};
const char* sensorNames[] = {"Temp", "Light"};
for(int [1] = 0; [1] < 2; [1]++) {
    printf("%s: %.2f\n", [2][[1]], [3][[1]]);
}
Drag options to blanks, or click blank then click option'
Ai
BsensorNames
CsensorValues
Dj
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong loop variable names.
Mixing up sensorNames and sensorValues arrays.