Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to turn on the LED by setting the pin high.
Embedded C
PORTB |= (1 << [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong pin number.
Forgetting to use bit shift operator.
✗ Incorrect
Pin 3 is used to control the LED, so setting bit 3 high turns it on.
2fill in blank
mediumComplete the code to configure pin 3 of PORTB as output.
Embedded C
DDRB |= (1 << [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Configuring the wrong pin.
Using '=' instead of '|=' operator.
✗ Incorrect
Setting bit 3 in DDRB configures pin 3 as an output.
3fill in blank
hardFix the error in the delay loop to create a visible LED blink.
Embedded C
for (int i = 0; i < [1]; i++) { __asm__("nop"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small a delay value.
Forgetting to include the loop.
✗ Incorrect
A delay of 1000 iterations creates a visible blink delay.
4fill in blank
hardFill both blanks to toggle the LED on pin 3 of PORTB.
Embedded C
PORTB [1]= (1 << [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR (|) instead of XOR (^).
Using wrong pin number.
✗ Incorrect
Using XOR (^) with bit 3 toggles the LED state.
5fill in blank
hardFill all four blanks to create a complete LED blink cycle: turn on, delay, turn off.
Embedded C
PORTB [1]= (1 << [2]); for (int i = 0; i < [3]; i++) { __asm__("nop"); } PORTB [4]= ~(1 << [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators for turning off the LED.
Delay too short to see blink.
✗ Incorrect
Use '|=' to turn on the LED, delay with 1000 loops, then '&=' with negated bit to turn off.