Untitled
unknown
plain_text
2 years ago
757 B
5
Indexable
import RPi.GPIO as GPIO
def are_all_gpios_in_use():
GPIO.setmode(GPIO.BCM) # Set pin numbering to Broadcom scheme
all_pins_in_use = True
for channel in range(2, 28): # GPIO pins typically range from 2 to 27 on Raspberry Pi
try:
function = GPIO.gpio_function(channel)
if function != GPIO.IN and function != GPIO.OUT:
all_pins_in_use = False
break
except ValueError:
# GPIO channel is invalid
continue
return all_pins_in_use
if __name__ == "__main__":
all_pins_in_use = are_all_gpios_in_use()
if all_pins_in_use:
print("All GPIO pins are in use.")
else:
print("Not all GPIO pins are in use.")
Editor is loading...
Leave a Comment