# Adafruit CircuitPython Wii Classic Controller Library

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/120/167/medium800/adafruit_products_edited_P1400322.jpg?1681219819)

[The Adafruit CircuitPython Wii Classic Controller library](https://github.com/adafruit/Adafruit_CircuitPython_Wii_Classic) will let you connect a [Wii Classic](https://en.wikipedia.org/wiki/Classic_Controller) compatible controller to an [Adafruit Wii Nunchuck Breakout Adapter](https://www.adafruit.com/product/4836) over STEMMA QT I2C to read incoming inputs from the controller. This means you could use these controllers in your next CircuitPython project to drive your robot, control your synth or run your NeoPixel light show.

You can use this CircuitPython driver with gamepads that have the notched plug connector. In addition to the original Wii Classic Controller, these include the NES and SNES-style controllers that were released with the [mini classic edition systems](https://en.wikipedia.org/wiki/NES_Classic_Edition). All of these controllers use the same I2C address ( **0x52** ) and button mappings. For example, pressing the A button on the Wii Classic controller or the SNES Classic controller will both be recognized by the driver as an A button input.

### Adafruit Wii Nunchuck Breakout Adapter

[Adafruit Wii Nunchuck Breakout Adapter](https://www.adafruit.com/product/4836)
Dig out that old Wii controller and use it as a sleek controller for your next robot if you like. The Adafruit Adafruit Wii Nunchuck Breakout Adapter fits snugly into the Wii connector and performs the level shifting and power regulation needed to use the controller with any microcontroller or...

In Stock
[Buy Now](https://www.adafruit.com/product/4836)
[Related Guides to the Product](https://learn.adafruit.com/products/4836/guides)
![Hand holding a Wiichuck controller pressing buttons. The controller is connected to the breakout wired to a Feather with OLED showing the streaming controller data](https://cdn-shop.adafruit.com/product-videos/640x480/4836-06.jpg)

## Community Bundle Library

There is a library in the [CircuitPython Community Bundle](https://github.com/adafruit/CircuitPython_Community_Bundle), the [CircuitPython\_WiiChuck library](https://github.com/jfurcean/CircuitPython_WiiChuck), that has drivers for a variety of additional Wii Remote accessories. Check it out if you're experimenting with some of the quirkier hardware that was released during the Wii console's reign.

# Adafruit CircuitPython Wii Classic Controller Library

## Library Syntax

![](https://cdn-learn.adafruit.com/assets/assets/000/120/168/medium800/adafruit_products_P1400311-2.jpg?1681219906)

The following page will walk you through the syntax for interfacing with the driver in CircuitPython to read your controller button presses. Note that depending on your controller, all of the functionality may not be available. For example, NES-style controllers will usually only have a D-Pad and buttons for A, B, Start and Select.

## Instantiate Over I2C

The I2C address for the controllers is **0x52** and it cannot be changed.

```python
import board
import adafruit_wii_classic

i2c = board.STEMMA_I2C()
ctrl_pad = adafruit_wii_classic.Wii_Classic(i2c)
```

Info: 

## D-Pad

- **Up button** -&nbsp;`ctrl_pad.d_pad.UP`
- **Down button** -&nbsp;`ctrl_pad.d_pad.DOWN`
- **Left button** - `ctrl_pad.d_pad.LEFT`
- **Right button** - `ctrl_pad.d_pad.RIGHT`

## Buttons

- **A button** -&nbsp;`ctrl_pad.buttons.A`
- **B button** - `ctrl_pad.buttons.B`
- **X button** - `ctrl_pad.buttons.X`
- **Y button** - `ctrl_pad.buttons.Y`
- **Start button** - `ctrl_pad.buttons.START`
- **Select button** - `ctrl_pad.buttons.SELECT`
- **Home button** - `ctrl_pad.buttons.HOME`
- **Left shoulder button** &nbsp;-&nbsp;`ctrl_pad.buttons.L`
- **Right shoulder button** - `ctrl_pad.buttons.R`
- **Z left button** - `ctrl_pad.buttons.ZL`
- **Z right button** - `ctrl_pad.buttons.ZR`

## Analog Joy Sticks

The Wii Classic-style controllers have two analog joysticks. Each joystick outputs an `x` and `y` axis value.

- **Left joystick** - `ctrl_pad.joystick_l
`
- **Right joystick** - `ctrl_pad.joystick_r`

You can assign two variables to each joystick object to read the `x` and `y` coordinates:

`left_x, left_y = ctrl_pad.joystick_l`

## Analog Shoulder Button Force

The official Wii Classic controllers have analog sensors in the left and right shoulder buttons, which let you read the force being applied to the button before it is fully pressed.

- **Left shoulder pressure** - `ctrl_pad.l_shoulder.LEFT_FORCE`
- **Right shoulder pressure** - `ctrl_pad.r_shoulder.RIGHT_FORCE`

# Adafruit CircuitPython Wii Classic Controller Library

## Example Code

![](https://cdn-learn.adafruit.com/assets/assets/000/120/165/medium800/adafruit_products_edited_P1400308-2.jpg?1681219687)

There are two examples included in the [Wii Classic Controller library](https://github.com/adafruit/Adafruit_CircuitPython_Wii_Classic): a simple test and a displayio visualizer. The simple test code listens for a few of the possible inputs from the controller and prints when they've been pressed to the REPL. The displayio visualizer displays a vector image of a controller to show when a button is pressed, as well as the x and y coordinates of the joysticks.

Both examples use a QT Py RP2040.

### Adafruit QT Py RP2040

[Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
What a cutie pie! Or is it... a QT Py?&nbsp;This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new [Raspberry Pi Pico](https://www.adafruit.com/pico) _and_ our [Feather...](http://www.adafruit.com/product/4884)

Out of Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)
![Video of hand holding a QT Py PCB in their hand. An LED glows rainbow colors.](https://cdn-shop.adafruit.com/product-videos/640x480/4900-06.jpg)

### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)
![Angled shot of STEMMA QT / Qwiic JST SH 4-pin Cable.](https://cdn-shop.adafruit.com/640x480/4210-00.jpg)

### Adafruit Wii Nunchuck Breakout Adapter

[Adafruit Wii Nunchuck Breakout Adapter](https://www.adafruit.com/product/4836)
Dig out that old Wii controller and use it as a sleek controller for your next robot if you like. The Adafruit Adafruit Wii Nunchuck Breakout Adapter fits snugly into the Wii connector and performs the level shifting and power regulation needed to use the controller with any microcontroller or...

In Stock
[Buy Now](https://www.adafruit.com/product/4836)
[Related Guides to the Product](https://learn.adafruit.com/products/4836/guides)
![Hand holding a Wiichuck controller pressing buttons. The controller is connected to the breakout wired to a Feather with OLED showing the streaming controller data](https://cdn-shop.adafruit.com/product-videos/640x480/4836-06.jpg)

## Simple Test Wiring
Plug the Nunchuck breakout into the STEMMA QT port on the QT Py RP2040.

Then, attach your controller to the Nunchuck breakout with the notch facing up towards the front of the breakout.

![adafruit_products_qtPyNunchuck_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/120/133/medium640/adafruit_products_qtPyNunchuck_bb.jpg?1681137912)

## Library Installation

To use with CircuitPython, you need to first install the Wii Classic controller library, and its dependencies, into the **lib** folder onto your **CIRCUITPY** drive. Then you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file.

Plug your CircuitPython compatible microcontroller into your computer via a known good USB cable. Be sure the cable has data+power wires. The board should show up as a new flash drive named **CIRCUITPY** in your computer File Explorer or Finder (depending on your operating system).

Extract the contents of the zip file, and copy the **entire lib folder** and the **code.py** file to your **CIRCUITPY** drive.

Your **CIRCUITPY/lib** folder should contain the following folder and file:

- **adafruit\_bus\_device/**
- **adafruit\_wii\_classic.mpy**

![CIRCUITPY](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/wii_classic_wii_classic_simpletest.py.png )

## Simple Test Example

Once everything is saved to the **CIRCUITPY** drive, [connect to the serial console](https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console) to see the data printed out!

https://github.com/adafruit/Adafruit_CircuitPython_Wii_Classic/blob/main/examples/wii_classic_simpletest.py

In the loop, the values of the two joysticks and the force readings from the two shoulder buttons are continuously printed to the REPL every 0.5 seconds. Please note that only the official Wii Classic controller has support for the shoulder button analog readings.

![](https://cdn-learn.adafruit.com/assets/assets/000/120/138/medium800/adafruit_products_analog.png?1681139964)

Info: 

If you press any of the d-pad buttons or the A or B buttons, they will be printed to the REPL.

![](https://cdn-learn.adafruit.com/assets/assets/000/120/139/medium800/adafruit_products_buttonREPL.png?1681140035)

## Displayio Visualizer Wiring
Connect the **Nunchuck breakout** to the **QT Py RP2040** via a **STEMMA QT cable**.

Then, connect the QT Py to the 2.2" TFT via an EYESPI breakout as follows.

- **EYESPI Vin** to **QT Py 3V (red wire)**
- **EYESPI GND** to **QT Py GND (black wire)&nbsp;**
- **EYESPI SCK** to **QT Py SCK (green wire)**
- **EYESPI MOSI** to **QT Py MO (white wire)**
- **EYESPI MISO** to **QT Py MI (orange wire)**
- **EYESPI DC** to **QT Py A1 (cyan wire)&nbsp;**
- **EYESPI RST** to **QT Py A3 (purple wire)**
- **EYESPI TCS** to **QT Py A2 (pink wire)**

![adafruit_products_qtPyNunchuckEYESPI_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/120/134/medium640/adafruit_products_qtPyNunchuckEYESPI_bb.jpg?1681138560)

### 2.2" 18-bit color TFT LCD display with microSD card breakout

[2.2" 18-bit color TFT LCD display with microSD card breakout](https://www.adafruit.com/product/1480)
This lovely little display breakout is the best way to add a small, colorful, and bright display to any project. Since the display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it can be used with every kind of microcontroller. Even a very small one with low...

In Stock
[Buy Now](https://www.adafruit.com/product/1480)
[Related Guides to the Product](https://learn.adafruit.com/products/1480/guides)
![Additional video of bootup animation test on TFT screen.](https://cdn-shop.adafruit.com/product-videos/640x480/1480-14.jpg)

### Adafruit EYESPI Breakout Board - 18 Pin FPC Connector

[Adafruit EYESPI Breakout Board - 18 Pin FPC Connector](https://www.adafruit.com/product/5613)
Our most recent [display breakouts have come with a new feature:&nbsp;an 18-pin "EYE SPI" standard FPC connector with flip-top connector](https://www.adafruit.com/?q=eyespi&sort=BestMatch). This is intended to be a sort-of "<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5613)
[Related Guides to the Product](https://learn.adafruit.com/products/5613/guides)
![Overhead video of a 1.9" TFT display connected via 18-pin FPC ribbon cable to a square-shaped microcontroller on a breadboard. The TFT plays an animated boot-up demo.](https://cdn-shop.adafruit.com/product-videos/640x480/5613-06.jpg)

### EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type

[EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type](https://www.adafruit.com/product/5239)
Connect this to that when a 18-pin FPC connector is needed. This 25 cm long cable is made of a flexible PCB. It's A-B style which means that pin one on one side will match with pin one on the other side. How handy!

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5239)
[Related Guides to the Product](https://learn.adafruit.com/products/5239/guides)
![Angled shot of a EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type. ](https://cdn-shop.adafruit.com/640x480/5239-00.jpg)

## Displayio Visualizer Example

In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, and copy the **entire lib folder** , the **code.py** file and the **wii\_classic.bmp** bitmap file to your **CIRCUITPY** drive.

Your **CIRCUITPY/lib** folder should contain the following files and folders:

- **adafruit\_bitmap\_font/**
- **adafruit\_bus\_device/**
- **adafruit\_display\_shapes/**
- **adafruit\_display\_text/**
- **adafruit\_ili9341.mpy**
- **adafruit\_wii\_classic.mpy**
- **simpleio.mpy**

![CIRCUITPY](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/wii_classic_wii_classic_displayio_visualizer.py.png )

https://github.com/adafruit/Adafruit_CircuitPython_Wii_Classic/blob/main/examples/wii_classic_displayio_visualizer.py

As you press the buttons on the controller, you'll see red circles appear on the picture of the controller. The `x` and `y` coordinates for each of the joysticks, as well as the force reading from the shoulder buttons (if applicable) are also displayed as text on the screen.

# Adafruit CircuitPython Wii Classic Controller Library

## Python Docs


## Featured Products

### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)
### Adafruit Wii Nunchuck Breakout Adapter

[Adafruit Wii Nunchuck Breakout Adapter](https://www.adafruit.com/product/4836)
Dig out that old Wii controller and use it as a sleek controller for your next robot if you like. The Adafruit Adafruit Wii Nunchuck Breakout Adapter fits snugly into the Wii connector and performs the level shifting and power regulation needed to use the controller with any microcontroller or...

In Stock
[Buy Now](https://www.adafruit.com/product/4836)
[Related Guides to the Product](https://learn.adafruit.com/products/4836/guides)
### Adafruit QT Py RP2040

[Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
What a cutie pie! Or is it... a QT Py?&nbsp;This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new [Raspberry Pi Pico](https://www.adafruit.com/pico) _and_ our [Feather...](http://www.adafruit.com/product/4884)

Out of Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)

## Related Guides

- [Adafruit Wii Nunchuck Breakout Adapter](https://learn.adafruit.com/adafruit-wii-nunchuck-breakout-adapter.md)
- [Adafruit QT Py RP2040](https://learn.adafruit.com/adafruit-qt-py-2040.md)
- [LEGO Set Lighting](https://learn.adafruit.com/lego-set-lighting.md)
- [NeoPixel Mini VU Meter](https://learn.adafruit.com/neopixel-mini-vu-meter.md)
- [PowerWash Simulator Nozzle Controller](https://learn.adafruit.com/powerwash-simulator-nozzle-controller.md)
- [LED Noodle Lantern](https://learn.adafruit.com/led-noodle-lantern.md)
- [Toddler Timer](https://learn.adafruit.com/toddler-timer.md)
- [Kitty Toe Bean Keypad with Color TFT](https://learn.adafruit.com/kitty-toe-bean-paw-keypad-color-tct.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [LED Noodle Holiday Tree](https://learn.adafruit.com/led-noodle-tree.md)
- [Adafruit I2S Amplifier BFF](https://learn.adafruit.com/i2s-amplifier-bff.md)
- [NeoPixel Novelty Cufflinks with Scrolling Text](https://learn.adafruit.com/neopixel-novelty-cufflinks-with-scrolling-text.md)
- [MIDI for Makers](https://learn.adafruit.com/midi-for-makers.md)
- [NeXT Bus Mouse to USB HID with CircuitPython](https://learn.adafruit.com/next-bus-mouse-to-usb-hid-with-circuitpython.md)
- [NeoKey Emoji Keyboard](https://learn.adafruit.com/neokey-emoji-keyboard.md)
- [SNES Mouse to USB HID with CircuitPython](https://learn.adafruit.com/snes-mouse-to-usb-hid-with-circuitpython.md)
- [MIDI Breath Controller](https://learn.adafruit.com/midi-breath-controller.md)
