Stufin
Home Quick Cart Profile

Raspberry Pi Pico

Buy Now on Stufin

Pin Configuration

  • Raspberry Pi Pico Pinout Guide
  • The Raspberry Pi Pico is a microcontroller board based on the RP2040 chip, featuring 40 pins that can be used for various applications. Here's a breakdown of each pin, its function, and how to connect them:
  • GPIO Pins (0-25)
  • GPIO 0 (Pin 1): General-purpose input/output pin. Can be used as an input, output, or for I2C communication.
  • GPIO 1 (Pin 2): General-purpose input/output pin. Can be used as an input, output, or for I2C communication.
  • ...
  • GPIO 25 (Pin 26): General-purpose input/output pin. Can be used as an input, output, or for I2C communication.
  • Analog-to-Digital Converter (ADC) Pins
  • ADC0 (Pin 27): Analog input pin for ADC channel 0.
  • ADC1 (Pin 28): Analog input pin for ADC channel 1.
  • ADC2 (Pin 29): Analog input pin for ADC channel 2.
  • ADC3 (Pin 30): Analog input pin for ADC channel 3.
  • Digital-to-Analog Converter (DAC) Pins
  • DAC0 (Pin 31): Analog output pin for DAC channel 0.
  • DAC1 (Pin 32): Analog output pin for DAC channel 1.
  • UART Pins
  • TX (Pin 33): UART transmit pin for serial communication.
  • RX (Pin 34): UART receive pin for serial communication.
  • SPI Pins
  • SCK (Pin 35): SPI clock pin for serial peripheral interface communication.
  • MOSI (Pin 36): SPI master out slave in pin for serial peripheral interface communication.
  • MISO (Pin 37): SPI master in slave out pin for serial peripheral interface communication.
  • CS (Pin 38): SPI chip select pin for serial peripheral interface communication.
  • I2C Pins
  • SCL (Pin 39): I2C clock pin for inter-integrated circuit communication.
  • SDA (Pin 40): I2C data pin for inter-integrated circuit communication.
  • Power Pins
  • VIN (Pin 39): Input voltage pin for powering the board (3.3V - 5.5V).
  • GND (Pin 38): Ground pin for the board.
  • 3V3 OUT (Pin 36): 3.3V output pin for powering external devices.
  • VBUS (Pin 37): 5V output pin for powering external devices (only when powered via USB).
  • Pin Connection Structure:
  • When connecting pins, ensure the correct polarity and voltage levels to avoid damage to the board or connected devices.
  • Use a breadboard or PCB to connect components to the Raspberry Pi Pico.
  • Connect GPIO pins to digital components, such as LEDs, buttons, or sensors, using jumper wires or PCB traces.
  • Connect analog pins to analog components, such as potentiometers or analog sensors, using jumper wires or PCB traces.
  • Connect UART, SPI, and I2C pins to corresponding pins on other devices, such as serial terminals, SPI devices, or I2C devices, using jumper wires or PCB traces.
  • Connect power pins to a power source, such as a battery or USB port, using a suitable connector or PCB traces.
  • Remember to always refer to the Raspberry Pi Pico datasheet and documentation for specific usage guidelines and safety precautions when working with the board.

Code Examples

Raspberry Pi Pico Documentation
Overview
The Raspberry Pi Pico is a microcontroller board developed by Raspberry Pi, a UK-based company. It is a small, low-cost, and highly capable board that is ideal for a wide range of applications, from simple prototypes to complex IoT projects. The Pico is based on the Raspberry Pi RP2040 microcontroller, which features a dual-core ARM Cortex-M0+ processor, 264KB of SRAM, and 2MB of flash storage.
Features
Dual-core ARM Cortex-M0+ processor
 264KB of SRAM
 2MB of flash storage
 26 multifunction GPIO pins
 3 analog inputs
 2 UARTs
 2 SPI interfaces
 1 I2C interface
 1 USB 1.1 interface
 Support for C/C++ and MicroPython programming languages
Code Examples
### Example 1: Blinking an LED using C/C++
This example demonstrates how to use the Raspberry Pi Pico to blink an LED connected to one of its GPIO pins.
Hardware Requirements
Raspberry Pi Pico board
 LED
 220 resistor
 Breadboard
 Jumper wires
Software Requirements
C/C++ compiler (e.g., GCC)
Code
```c
#include <iostream>
#include <rp2040.h>
int main() {
    // Initialize the GPIO pin as an output
    gpio_init(25); // GPIO 25 is used as an example, change to the pin connected to your LED
    gpio_set_dir(25, GPIO_OUT);
while (true) {
        // Set the GPIO pin high to turn the LED on
        gpio_put(25, 1);
        delay_ms(500);
// Set the GPIO pin low to turn the LED off
        gpio_put(25, 0);
        delay_ms(500);
    }
    return 0;
}
```
Explanation
This code initializes the GPIO pin as an output and sets it high to turn the LED on, then sets it low to turn the LED off, creating a blinking effect.
### Example 2: Reading Temperature Data using MicroPython
This example demonstrates how to use the Raspberry Pi Pico to read temperature data from a DS18B20 temperature sensor using MicroPython.
Hardware Requirements
Raspberry Pi Pico board
 DS18B20 temperature sensor
 Breadboard
 Jumper wires
Software Requirements
MicroPython firmware (e.g., version 1.15.0 or later)
Code
```python
import machine
import ds18x20
# Initialize the DS18B20 temperature sensor
ds_sensor = ds18x20.DS18X20(machine.Pin(4))  # Pin 4 is used as an example, change to the pin connected to your sensor
while True:
    # Read the temperature data from the sensor
    temp_c = ds_sensor.read_temp()
    print("Temperature: {:.1f}C".format(temp_c))
    time.sleep(1)
```
Explanation
This code initializes the DS18B20 temperature sensor and reads the temperature data from it using the `read_temp()` method. The temperature data is then printed to the console.
These examples demonstrate the basic capabilities of the Raspberry Pi Pico and its ease of use in various IoT applications. The Pico's flexibility and affordability make it an ideal choice for prototyping and developing a wide range of projects.