树莓派5对应gpio引脚
时间: 2025-05-25 16:29:42 浏览: 33
### Raspberry Pi 5 GPIO Pinout Diagram and Documentation
For the Raspberry Pi 5, understanding its General Purpose Input Output (GPIO) pins is crucial for projects involving hardware interfacing such as controlling LEDs with GPIO signals. The official documentation provides a comprehensive overview of all available GPIO pins on this model.
The Raspberry Pi 5 features a standard 40-pin header which includes multiple types of pins like power supply, ground, UART, SPI, I2C, PWM, and general-purpose input/output lines that can be configured either as inputs or outputs depending upon requirements[^1].
To achieve stable signal detection using an LED controlled by GPIO based on high/low voltage levels from switches:
- When configuring GPIOs to control devices like LEDs, ensure proper setup scripts are used.
A typical Python script might look something similar to below where `BCM` numbering scheme has been adopted instead of physical pin numbers due to better portability across different models including Raspberry Pi 5:
```python
import RPi.GPIO as GPIO
from time import sleep
led_pin = 18 # BCM number corresponding to your wiring configuration
def setup():
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)
try:
while True:
user_input = int(input("Enter 1 to turn ON LED; Enter 0 to turn OFF LED: "))
if user_input == 1:
GPIO.output(led_pin, GPIO.HIGH)
elif user_input == 0:
GPIO.output(led_pin, GPIO.LOW)
finally:
GPIO.cleanup()
```
This code snippet demonstrates how one could interactively switch between HIGH and LOW states thus turning an attached LED on/off according to given instructions through console input.
阅读全文
相关推荐




















