Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: pico_pinout2.py
- # Author: Jeoi Reqi
- """
- Pico Pinout 2 - Raspberry Pi Pico Pinout Mapping Script
- Description:
- This script provides a comprehensive pinout mapping for the Raspberry Pi Pico microcontroller output to the terminal in plain text.
- It assists users in understanding the functions associated with each GPIO pin, their aliases, and the corresponding pin types.
- The pin types include information on whether a pin serves as a digital input/output, analog input, or has a special function.
- Usage:
- 1. Make sure you have CircuitPython installed on your Raspberry Pi Pico.
- 2. Connect your Pico to your computer via USB.
- 3. Run this script to generate a detailed pinout mapping for the Raspberry Pi Pico.
- Requirements:
- - Adafruit CircuitPython library installed on your Raspberry Pi Pico.
- - Compatible hardware setup with Raspberry Pi Pico.
- For Adafruit CircuitPython setup instructions, visit:
- https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/overview
- Note: Ensure your CircuitPython is properly installed before running this script.
- Enjoy exploring the capabilities of your Raspberry Pi Pico with this convenient pinout mapping tool!
- """
- import microcontroller
- import board
- from collections import OrderedDict
- board_pins_mapping = OrderedDict([
- ("GPIO1", 1),
- ("GPIO2", 2),
- ("GPIO3 (Ground)", 3),
- ("GPIO4", 4),
- ("GPIO5", 5),
- ("GPIO6", 6),
- ("GPIO7", 7),
- ("GPIO8 (Ground)", 8),
- ("GPIO9", 9),
- ("GPIO10", 10),
- ("GPIO11", 11),
- ("GPIO12", 12),
- ("GPIO13 (Ground)", 13),
- ("GPIO14", 14),
- ("GPIO15", 15),
- ("GPIO16", 16),
- ("GPIO17", 17),
- ("GPIO18 (Ground)", 18),
- ("GPIO19", 19),
- ("GPIO20", 20),
- ("GPIO21", 21),
- ("GPIO22", 22),
- ("GPIO23 (Ground)", 23),
- ("GPIO24", 24),
- ("GPIO25", 25),
- ("GPIO26", 26),
- ("GPIO27", 27),
- ("GPIO28 (Ground)", 28),
- ("GPIO29", 29),
- ("RUN (Reset)", 30),
- ("GPIO31", 31),
- ("GPIO32", 32),
- ("GPIO33 (Ground, Analog Ground)", 33),
- ("GPIO34", 34),
- ("ADC_VREF", 35),
- ("3V3 (3.3V Output)", 36),
- ("3V3_EN (Enable 3V3 Output)", 37),
- ("GPIO38 (Ground)", 38),
- ("VSYS (System Voltage)", 39),
- ("VBUS (Power Input)", 40),
- ("DEBUG-SWCLK", 41),
- ("DEBUG-GND (Ground)", 42),
- ("DEBUG-SWDIO", 43)
- ])
- # Pin Types
- pin_types = {
- 1: "SPI0 RX, I2C0 SDA, UART0 TX",
- 2: "SPI0 CSn, I2C0 SCL, UART0 RX",
- 3: "Ground",
- 4: "SPI0 SCK, I2C1 SDA, UART0 CTS",
- 5: "SPI0 TX, I2C1 SCL, UART0 RTS",
- 6: "SPI0 RX, I2C0 SDA, UART1 TX",
- 7: "SPI0 CSn, I2C0 SCL, UART1 RX",
- 8: "Ground",
- 9: "SPI0 SCK, I2C1 SDA, UART1 CTS",
- 10: "SPI0 TX, I2C1 SCL, UART1 RTS",
- 11: "SPI1 RX, I2C0 SDA, UART1 TX",
- 12: "SPI1 CSn, I2C0 SCL, UART1 RX",
- 13: "Ground",
- 14: "SPI1 SCK, I2C1 SDA, UART1 CTS",
- 15: "SPI1 TX, I2C1 SCL, UART1 RTS",
- 16: "SPI1 RX, I2C0 SDA, UART0 TX",
- 17: "SPI1 CSn, I2C0 SCL, UART0 RX",
- 18: "Ground",
- 19: "SPI1 SCK, I2C1 SDA, UART0 CTS",
- 20: "SPI1 TX, I2C1 SCL, UART0 RTS",
- 21: "I2C0 SCL, UART1 RX",
- 22: "I2C0 SDA, UART1 TX",
- 23: "Ground",
- 24: "SPI0 CSn, I2C",
- 25: "SPI0 TX, I2C1 SCL, UART0 RTS",
- 26: "I2C0 SDA, UART1 TX",
- 27: "I2C0 SCL, UART1 RX",
- 28: "Ground",
- 29: "SPI0 SCK, I2C1 SDA, UART1 CTS",
- 30: "Reset Button",
- 31: "ADC0",
- 32: "ADC1, I2C1 SCL, UART1 RTS",
- 33: "Ground",
- 34: "ADC2, UART0 TX",
- 35: "ADC_VREF",
- 36: "3.3V Output",
- 37: "Enable 3V3 Output",
- 38: "Ground",
- 39: "System Voltage",
- 40: "Power Input",
- 41: "DEBUG",
- 42: "DEBUG Ground",
- 43: "DEBUG"
- }
- # Print Pin Mapping
- print("------------------------------------------------------------------------------------------\n\t\t\t[Raspberry Pi Pico Board Pins]\n------------------------------------------------------------------------------------------\n\n\n---------\t-------------\t\t\t--------------\t\t------------------\nGPIO Pin:\tAlias:\t\t\t\tPin Functions:\t\t\tPin Types:\n---------\t-------------\t\t\t--------------\t\t------------------\n")
- for pin, number in board_pins_mapping.items():
- pin_alias = pin
- pin_functions = pin_types.get(number, "Unknown")
- print("GPIO {}: \t{}\t\t\t{}\t\t{}".format(number, pin_alias, pin_functions, pin_types[number]))
- print("\n------------------------------------------------------------------------------------------\n\t\t\t\t\tEND\n------------------------------------------------------------------------------------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement