0
0
Embedded Cprogramming~10 mins

Why ADC is needed in Embedded C - Test Your Understanding

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

Complete the code to declare an ADC input pin.

Embedded C
int adc_pin = [1];
Drag options to blanks, or click blank then click option'
A13
BLED_BUILTIN
CD13
DA0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a digital pin number instead of an analog pin label.
2fill in blank
medium

Complete the code to read the analog value from the ADC pin.

Embedded C
int sensor_value = [1](adc_pin);
Drag options to blanks, or click blank then click option'
AdigitalRead
BanalogRead
CreadADC
DgetAnalog
Attempts:
3 left
💡 Hint
Common Mistakes
Using digitalRead() instead of analogRead().
3fill in blank
hard

Fix the error in the code to convert the ADC value to voltage.

Embedded C
float voltage = sensor_value [1] 1023.0 * 5.0;
Drag options to blanks, or click blank then click option'
A/
B*
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of division for scaling.
4fill in blank
hard

Fill both blanks to create a dictionary of ADC values above threshold.

Embedded C
adc_values = {pin: value [1] value for pin, value in readings.items() if value [2] 500}
Drag options to blanks, or click blank then click option'
A*
B>
C<
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' instead of '+' for addition.
Using '<' instead of '>' for filtering.
5fill in blank
hard

Fill all three blanks to calculate average voltage from ADC readings.

Embedded C
average_voltage = sum([1]) [2] len(adc_readings) [3] 5.0 / 1023.0
Drag options to blanks, or click blank then click option'
Aadc_readings
B/
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '*' for voltage scaling.
Dividing by voltage instead of multiplying.