Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set pin 5 as an output.
Embedded C
DDRB |= (1 << [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong pin number in the bit shift.
Forgetting to use the bitwise OR operator.
✗ Incorrect
Setting bit 5 in DDRB configures pin 5 as an output.
2fill in blank
mediumComplete the code to configure pin 2 as an input.
Embedded C
DDRD &= ~(1 << [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using bitwise OR instead of AND to clear the bit.
Shifting by the wrong pin number.
✗ Incorrect
Clearing bit 2 in DDRD configures pin 2 as an input.
3fill in blank
hardFix the error in the code to set pin 7 as output.
Embedded C
DDRC [1] (1 << 7);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which overwrites the entire register.
Using '&=' which clears bits instead of setting.
✗ Incorrect
Use '|=' to set bit 7 without affecting other bits.
4fill in blank
hardFill both blanks to configure pin 4 as input and enable pull-up resistor.
Embedded C
DDRB [1] ~(1 << 4); PORTB [2] (1 << 4);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '&=' or '|='.
Not enabling the pull-up resistor after setting input.
✗ Incorrect
Use '&=' with negated bit mask to set pin as input, and '|=' to enable pull-up resistor.
5fill in blank
hardFill all three blanks to configure pin 3 as output, set it high, and clear pin 6 as input.
Embedded C
DDRD [1] (1 << 3); PORTD [2] (1 << 3); DDRD [3] ~(1 << 6);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '^=' which toggles bits instead of setting or clearing.
Mixing up PORTD and DDRD registers.
✗ Incorrect
Use '|=' to set pin 3 as output and set it high, and '&=' with negation to clear pin 6 as input.