This PlatformIO project turns a Raspberry Pi Pico into a Nintendo GameCube controller. The Pico emulates the GameCube controller protocol, allowing it to be used with GameCube consoles or adapters.
- Full GameCube controller protocol implementation
- Support for all buttons (A, B, X, Y, Start, Z, L, R, D-Pad)
- Analog stick support (main stick and C-stick)
- Analog trigger support (L and R triggers)
- Precise timing using bit-banging on GPIO
- 3.3V logic compatible (no level shifters needed!)
- Raspberry Pi Pico
- GameCube controller cable or connector
- Buttons/switches for controller inputs
- Potentiometers for analog sticks (optional)
- Resistors (1kΩ pullup recommended for data line)
Looking at the controller port on the console (socket):
___
/ \
| 6 1 |
| 5 3 2 |
\ 4 /
---
- 5V - Not needed (Pico has own power)
- Data - Connect to GPIO 2 on Pico (with 1kΩ pullup to 3.3V)
- Ground - Connect to Pico GND
- Ground - Connect to Pico GND
- No connection
- 3.3V - Can be used to power Pico (or use USB)
The default pin mapping in include/button_mapping.h:
| Button | GPIO Pin | Notes |
|---|---|---|
| A | 3 | Active low with pullup |
| B | 4 | Active low with pullup |
| X | 5 | Active low with pullup |
| Y | 6 | Active low with pullup |
| Start | 7 | Active low with pullup |
| Z | 8 | Active low with pullup |
| L | 9 | Active low with pullup |
| R | 10 | Active low with pullup |
| D-Up | 11 | Active low with pullup |
| D-Down | 12 | Active low with pullup |
| D-Left | 13 | Active low with pullup |
| D-Right | 14 | Active low with pullup |
| Main Stick X | 26 (ADC0) | Analog input |
| Main Stick Y | 27 (ADC1) | Analog input |
| C-Stick X | 28 (ADC2) | Analog input |
| C-Stick Y | 29 (ADC3) | Analog input |
| L Analog | 15 | Digital or analog |
| R Analog | 16 | Digital or analog |
- All button pins use internal pullup resistors and are active low
- Connect buttons between GPIO pin and GND
- The GameCube data line requires a 1kΩ pullup resistor to 3.3V
- GameCube uses 3.3V logic, perfect for the Pico (no level shifting needed)
- Install Visual Studio Code
- Install the PlatformIO extension
- Open this folder in VS Code
- PlatformIO should automatically detect the project
- Connect your Raspberry Pi Pico while holding the BOOTSEL button
- The Pico should appear as a USB mass storage device
- Build the project: Click the checkmark (✓) in the PlatformIO toolbar
- Upload: Click the arrow (→) in the PlatformIO toolbar
Alternatively, use the command line:
pio run -t uploadTo see debug output:
- Connect via USB
- Click the plug icon in PlatformIO toolbar for Serial Monitor
- Or use:
pio device monitor
Edit include/button_mapping.h to change which GPIO pins are used for each button.
The current updateControllerState() function in src/main.cpp has demo code. Replace it with real button reading:
void updateControllerState() {
// Read digital buttons
controller_state.buttons1 = 0;
if (readButton(PIN_BTN_START)) controller_state.buttons1 |= BTN_START;
if (readButton(PIN_BTN_Y)) controller_state.buttons1 |= BTN_Y;
if (readButton(PIN_BTN_X)) controller_state.buttons1 |= BTN_X;
if (readButton(PIN_BTN_B)) controller_state.buttons1 |= BTN_B;
if (readButton(PIN_BTN_A)) controller_state.buttons1 |= BTN_A;
controller_state.buttons2 = 0;
if (readButton(PIN_BTN_L)) controller_state.buttons2 |= BTN_L;
if (readButton(PIN_BTN_R)) controller_state.buttons2 |= BTN_R;
if (readButton(PIN_BTN_Z)) controller_state.buttons2 |= BTN_Z;
if (readButton(PIN_BTN_DUP)) controller_state.buttons2 |= BTN_DUP;
if (readButton(PIN_BTN_DDOWN)) controller_state.buttons2 |= BTN_DDOWN;
if (readButton(PIN_BTN_DRIGHT)) controller_state.buttons2 |= BTN_DRIGHT;
if (readButton(PIN_BTN_DLEFT)) controller_state.buttons2 |= BTN_DLEFT;
// Read analog sticks
controller_state.stick_x = adcToJoystick(analogRead(PIN_STICK_X));
controller_state.stick_y = adcToJoystick(analogRead(PIN_STICK_Y));
controller_state.cstick_x = adcToJoystick(analogRead(PIN_CSTICK_X));
controller_state.cstick_y = adcToJoystick(analogRead(PIN_CSTICK_Y));
// Read analog triggers
controller_state.l_analog = readButton(PIN_L_ANALOG) ? 255 : 0;
controller_state.r_analog = readButton(PIN_R_ANALOG) ? 255 : 0;
}The GameCube controller protocol uses a single bidirectional data line with precise timing:
- Logic 0: 3μs low, 1μs high
- Logic 1: 1μs low, 3μs high
- Stop bit: 1μs low, 2μs high
0x00or0xFF: Initialize/Reset - Controller responds with ID0x40or0x41: Poll - Controller sends 8 bytes of state data0x42: Origin - Read calibration data (not fully implemented)
- Byte 0: Start, Y, X, B, A, -, -, -
- Byte 1: L, R, Z, D-Up, D-Down, D-Right, D-Left, -
- Byte 2: Main stick X (0-255, 128 = center)
- Byte 3: Main stick Y (0-255, 128 = center)
- Byte 4: C-stick X (0-255, 128 = center)
- Byte 5: C-stick Y (0-255, 128 = center)
- Byte 6: L trigger analog (0-255)
- Byte 7: R trigger analog (0-255)
- Check the data line connection and pullup resistor
- Verify ground connections
- Check serial monitor for debug messages
- Ensure timing is accurate (try adjusting microsecond delays)
- Verify pin assignments in
button_mapping.h - Check that buttons are wired correctly (active low)
- Uncomment button reading code in
updateControllerState()
- Calibrate the center point of your potentiometers
- Add deadzone handling in the code
- Check ADC connections
- Use PIO state machines for more accurate timing
- Add rumble motor support (requires additional hardware)
- Implement origin/calibration command fully
- Add USB HID mode to work as a PC game controller
- Support for multiple controller profiles
- GameCube Controller Protocol Documentation
- Raspberry Pi Pico Datasheet
- Nintendo GameCube Hardware Specs
This project is provided as-is for educational and hobbyist purposes. Nintendo and GameCube are trademarks of Nintendo Co., Ltd.
Feel free to submit issues and pull requests to improve this project!