Untitled
unknown
plain_text
a year ago
606 B
3
Indexable
import RPi.GPIO as GPIO def list_active_gpios(): GPIO.setmode(GPIO.BCM) # Set pin numbering to Broadcom scheme active_gpios = [] for pin in range(2, 28): # GPIO pins typically range from 2 to 27 on Raspberry Pi try: GPIO.setup(pin, GPIO.IN) GPIO.input(pin) active_gpios.append(pin) except RuntimeError: continue GPIO.cleanup() # Clean up GPIO to return to a clean state return active_gpios if __name__ == "__main__": active_gpios = list_active_gpios() print("Active GPIOs:", active_gpios)
Editor is loading...
Leave a Comment