code.py
1 # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 """CircuitPython Essentials PWM pin identifying script""" 6 import board 7 import pwmio 8 9 for pin_name in dir(board): 10 pin = getattr(board, pin_name) 11 try: 12 p = pwmio.PWMOut(pin) 13 p.deinit() 14 print("PWM on:", pin_name) # Prints the valid, PWM-capable pins! 15 except ValueError: # This is the error returned when the pin is invalid. 16 print("No PWM on:", pin_name) # Prints the invalid pins. 17 except RuntimeError: # Timer conflict error. 18 print("Timers in use:", pin_name) # Prints the timer conflict pins. 19 except TypeError: # Error returned when checking a non-pin object in dir(board). 20 pass # Passes over non-pin objects in dir(board).