0
0
Embedded Cprogramming~10 mins

First embedded program (LED blink) 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 turn on the LED by setting the pin high.

Embedded C
PORTB |= (1 << [1]);
Drag options to blanks, or click blank then click option'
A5
B7
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong pin number.
Forgetting to use bit shift operator.
2fill in blank
medium

Complete 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'
A4
B3
C2
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Configuring the wrong pin.
Using '=' instead of '|=' operator.
3fill in blank
hard

Fix 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'
A1000
B100
C10
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small a delay value.
Forgetting to include the loop.
4fill in blank
hard

Fill 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'
A^
B|
C3
D&
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR (|) instead of XOR (^).
Using wrong pin number.
5fill in blank
hard

Fill 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'
A|=
B3
C1000
D&=
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators for turning off the LED.
Delay too short to see blink.