0
0
Raspberry Piprogramming~10 mins

Setting pin mode (IN, OUT) in Raspberry Pi - Interactive Code Practice

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

Complete the code to set GPIO pin 17 as an output.

Raspberry Pi
GPIO.setup(17, GPIO.[1])
Drag options to blanks, or click blank then click option'
AOUT
BHIGH
CLOW
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IN' instead of 'OUT' when setting output mode.
Confusing pin mode with pin state (HIGH/LOW).
2fill in blank
medium

Complete the code to set GPIO pin 22 as an input.

Raspberry Pi
GPIO.setup(22, GPIO.[1])
Drag options to blanks, or click blank then click option'
AOUT
BIN
CHIGH
DLOW
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OUT' instead of 'IN' when setting input mode.
Confusing pin mode with pin state.
3fill in blank
hard

Fix the error in setting pin 5 mode to output.

Raspberry Pi
GPIO.setup(5, GPIO.[1])
Drag options to blanks, or click blank then click option'
AINPUT
BIN
COUTPUT
DOUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OUTPUT' instead of 'OUT'.
Using 'INPUT' instead of 'IN'.
4fill in blank
hard

Fill both blanks to set pin 13 as input with a pull-up resistor.

Raspberry Pi
GPIO.setup(13, GPIO.[1], pull_up_down=GPIO.[2])
Drag options to blanks, or click blank then click option'
AIN
BOUT
CPUD_UP
DPUD_DOWN
Attempts:
3 left
💡 Hint
Common Mistakes
Using output mode instead of input.
Using pull-down resistor instead of pull-up.
5fill in blank
hard

Fill all three blanks to set pin 18 as output and set it HIGH.

Raspberry Pi
GPIO.setup(18, GPIO.[1])
GPIO.output(18, GPIO.[2])
state = GPIO.input(18) == GPIO.[3]
Drag options to blanks, or click blank then click option'
AIN
BOUT
CHIGH
DLOW
Attempts:
3 left
💡 Hint
Common Mistakes
Using input mode instead of output.
Setting pin state to LOW instead of HIGH.
Comparing input to LOW instead of HIGH.