rpi pico_usb device mode - dwilson2547/wiki_demo GitHub Wiki

how to i put a raspberry pi pico into usb device mode?

Edit To put a Raspberry Pi Pico into USB device mode, you have several options depending on what you want to achieve:

Boot Selection (BOOTSEL) Mode The easiest way is to use the built-in BOOTSEL mode:

Hold the BOOTSEL button while plugging the Pico into your computer via USB The Pico will appear as a USB mass storage device (like a USB drive) You can then drag and drop .uf2 firmware files directly onto it Programming USB Device Functionality If you want to program the Pico to act as a USB device (like a keyboard, mouse, or custom HID device):

Using CircuitPython:

import usb_hid
import usb_cdc
# Pico automatically enters USB device mode when running CircuitPython

Using MicroPython:

# MicroPython has limited USB HID support
# You may need to use specific libraries or switch to C/C++

Using C/C++ with Pico SDK:

#include "pico/stdlib.h"
#include "tusb.h"

int main() {
    stdio_init_all();
    tusb_init(); // Initialize TinyUSB stack
    
    while (1) {
        tud_task(); // TinyUSB device task
        // Your USB device code here
    }
}

Force Device Mode Programmatically In your code, you can also force USB device mode:

// In C/C++
#include "pico/bootrom.h"
reset_usb_boot(0, 0); // Reboot into BOOTSEL mode

The Pico automatically operates in USB device mode when connected to a host computer - you don't need special configuration unless you're implementing specific USB device classes (HID, CDC, etc.).

⚠️ **GitHub.com Fallback** ⚠️