Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the GPIO mode to BCM numbering.
Raspberry Pi
import RPi.GPIO as GPIO GPIO.setmode(GPIO.[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BOARD instead of BCM for BCM numbering.
✗ Incorrect
BCM mode uses the Broadcom chip's pin numbers.
2fill in blank
mediumComplete the code to set up pin 18 as an output using BCM numbering.
Raspberry Pi
GPIO.setup([1], GPIO.OUT) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using physical pin numbers instead of BCM numbers.
✗ Incorrect
Pin 18 is a common GPIO pin in BCM mode.
3fill in blank
hardFix the error in the code to set the GPIO mode to BOARD numbering.
Raspberry Pi
GPIO.setmode(GPIO.[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BCM instead of BOARD for physical pin numbering.
✗ Incorrect
BOARD mode uses the physical pin numbers on the Raspberry Pi header.
4fill in blank
hardFill both blanks to create a dictionary mapping physical pins to BCM pins for pins 7 and 11.
Raspberry Pi
pin_map = {7: [1], 11: [2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up physical and BCM pin numbers.
✗ Incorrect
Physical pin 7 maps to BCM 4, and physical pin 11 maps to BCM 17.
5fill in blank
hardFill all three blanks to set up physical pin 12 as output, set it high, and then clean up.
Raspberry Pi
GPIO.setmode(GPIO.[1]) GPIO.setup([2], GPIO.OUT) GPIO.output([3], GPIO.HIGH) GPIO.cleanup()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BCM mode but physical pin numbers.
✗ Incorrect
Use BOARD mode for physical pin numbering, set up pin 12 as output, then set it high.