0
0
Raspberry Piprogramming~10 mins

Pull-up and pull-down resistors 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 a GPIO pin as input with a pull-up resistor.

Raspberry Pi
GPIO.setup(17, GPIO.IN, pull_up_down=[1])
Drag options to blanks, or click blank then click option'
AGPIO.PUD_DOWN
BGPIO.IN
CGPIO.OUT
DGPIO.PUD_UP
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.PUD_DOWN instead of GPIO.PUD_UP
Setting pin as output instead of input
2fill in blank
medium

Complete the code to read the state of a GPIO pin configured with a pull-down resistor.

Raspberry Pi
state = GPIO.input([1])
Drag options to blanks, or click blank then click option'
AGPIO.OUT
BGPIO.PUD_DOWN
C18
DGPIO.IN
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.PUD_DOWN instead of pin number
Using GPIO.IN as argument
3fill in blank
hard

Fix the error in the code to correctly set a GPIO pin with a pull-down resistor.

Raspberry Pi
GPIO.setup(22, [1], pull_up_down=GPIO.PUD_DOWN)
Drag options to blanks, or click blank then click option'
AGPIO.IN
BGPIO.PUD_UP
CGPIO.OUT
DGPIO.PUD_DOWN
Attempts:
3 left
💡 Hint
Common Mistakes
Setting pin as output
Using pull-up resistor instead of pull-down
4fill in blank
hard

Fill both blanks to create a dictionary mapping pin numbers to their pull resistor types.

Raspberry Pi
pin_resistors = {17: [1], 18: [2]
Drag options to blanks, or click blank then click option'
AGPIO.PUD_UP
BGPIO.OUT
CGPIO.PUD_DOWN
DGPIO.IN
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.OUT or GPIO.IN as resistor types
5fill in blank
hard

Fill all three blanks to set up pin 23 as input with pull-up resistor and read its state.

Raspberry Pi
GPIO.setup([1], [2], pull_up_down=[3])
state = GPIO.input(23)
Drag options to blanks, or click blank then click option'
A23
BGPIO.IN
CGPIO.PUD_UP
DGPIO.OUT
Attempts:
3 left
💡 Hint
Common Mistakes
Setting pin as output
Using pull-down resistor instead of pull-up