Raspberry Pi - Automation and SchedulingWhich of the following Python code snippets correctly initializes GPIO pin 18 for relay control using RPi.GPIO?AGPIO.setup(18, GPIO.IN)BGPIO.setup(18, GPIO.OUT)CGPIO.setup(18, GPIO.PWM)DGPIO.setup(18, GPIO.ALT)Check Answer
Step-by-Step SolutionSolution:Step 1: Recall correct GPIO setup for relayRelay control requires output mode, so GPIO.OUT is needed.Step 2: Check syntax correctnessGPIO.setup(pin_number, mode) is the correct function call; GPIO.setup(18, GPIO.OUT) is valid.Final Answer:GPIO.setup(18, GPIO.OUT) -> Option BQuick Check:GPIO setup for relay = GPIO.OUT [OK]Quick Trick: Use GPIO.setup(pin, GPIO.OUT) to control relays [OK]Common Mistakes:MISTAKESSetting pin as inputUsing invalid mode like GPIO.PWMIncorrect function parameters
Master "Automation and Scheduling" in Raspberry Pi9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Raspberry Pi Quizzes Automation and Scheduling - Cron jobs for scheduled tasks - Quiz 1easy Automation and Scheduling - Email alerts on sensor thresholds - Quiz 5medium Data Logging and Databases - Why data logging matters for IoT - Quiz 13medium MQTT for IoT - Multi-device MQTT network - Quiz 8hard MQTT for IoT - MQTT with QoS levels - Quiz 15hard Security and Deployment - Headless deployment setup - Quiz 1easy Security and Deployment - User authentication basics - Quiz 10hard Security and Deployment - Backup and recovery strategies - Quiz 13medium Web Server and API - Why web servers enable remote IoT control - Quiz 15hard Web Server and API - Controlling GPIO through web interface - Quiz 13medium