Raspberry Pi - LED and Button ProjectsWhich Python code snippet correctly sets up GPIO pin 17 as an input for a button on Raspberry Pi?AGPIO.setup(17, GPIO.OUT)BGPIO.setup(17, GPIO.IN)CGPIO.input(17, GPIO.IN)DGPIO.output(17, GPIO.IN)Check Answer
Step-by-Step SolutionSolution:Step 1: Recall GPIO setup syntaxTo set a pin as input, use GPIO.setup(pin_number, GPIO.IN).Step 2: Match the correct optionGPIO.setup(17, GPIO.IN) uses GPIO.setup(17, GPIO.IN), which is correct for input pin setup.Final Answer:GPIO.setup(17, GPIO.IN) -> Option BQuick Check:GPIO.setup(pin, GPIO.IN) sets input pin [OK]Quick Trick: Use GPIO.setup with GPIO.IN for input pins [OK]Common Mistakes:Using GPIO.OUT instead of GPIO.IN for inputConfusing GPIO.input() with GPIO.setup()Trying to use GPIO.output() on input pins
Master "LED and Button Projects" in Raspberry Pi9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Raspberry Pi Quizzes GPIO Basics with Python - GPIO cleanup on exit - Quiz 1easy GPIO Basics with Python - GPIO cleanup on exit - Quiz 4medium LED and Button Projects - Button with interrupt (GPIO.add_event_detect) - Quiz 13medium LED and Button Projects - Multiple LED patterns - Quiz 7medium PWM Output - Software PWM with RPi.GPIO - Quiz 13medium Raspberry Pi Platform - Operating system setup (Raspberry Pi OS) - Quiz 7medium gpiozero Library - MotionSensor (PIR) - Quiz 5medium gpiozero Library - LED class and methods - Quiz 12easy gpiozero Library - Button class with callbacks - Quiz 11easy gpiozero Library - LED class and methods - Quiz 14medium