# PlayStation Spinner Controller

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/121/970/medium800/hacks_psx-3522.jpg?1687295360)

https://youtu.be/4LS5t62OTvU

Harness the power of a very specific and weird PlayStation controller! The Takara Game of Life controller is just like a normal PlayStation (PSX) controller, with a twist -- literally -- it has a colorful spinner on it that you can twirl like a roulette wheel to spam the circle button!&nbsp;

While this was originally designed for use with a specific Game of Life game on PSX, you can bring it into the modern era an turn it into a USB controller that can be used for emulation, game control, and perhaps most importantly -- as a very fast mouse clicker!

Using a QT Py RP2040 running CircuitPython and the ps2controller library by Tod Kurt, this novelty controller can be used on your computer or mobile device, sending USB HID keyboard and mouse commands, or, alternatively as a USB MIDI controller.

## Parts
Featured
### 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)

In 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)

### Takara TAKC-00001 PlayStation Controller

Phil Torrone has a great talent for discovering unusual video game controllers. He found this one and said, "JP, get this and see what you can do with it!" -- it's not very easy to find, partly as it was only released for the Japanese market it seems, but you can find them on [eBay](https://www.ebay.com/sch/i.html?_from=R40&_trksid=p2334524.m570.l1313&_nkw=takara+TAKC-00001&_sacat=0&LH_TitleDesc=0&_odkw=takara+playstation+roulette&_osacat=0&LH_PrefLoc=2) and other online auction sites.

![hacks_psx-3456b.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/968/medium640/hacks_psx-3456b.jpg?1687294317)

Featured
### PlayStation Extension Cable - Compatible with PS1 and 2

[PlayStation Extension Cable - Compatible with PS1 and 2](https://www.adafruit.com/product/5773)
Ostensibly this extension cord was originally designed to allow PlayStation game players to be able to sit across the room from their game system, but what we are using it for is to connect to PS controllers and accessories without soldering directly to cables or cutting the connectors off....

In Stock
[Buy Now](https://www.adafruit.com/product/5773)
[Related Guides to the Product](https://learn.adafruit.com/products/5773/guides)
![Angled shot of 2m long PlayStation extension cable.](https://cdn-shop.adafruit.com/640x480/5773-02.jpg)

### PlayStation Controller Extension Cable

These inexpensive connector cables are great for building DIY PSX and PS2 breakouts (the PlayStation and PlayStation 2 use the same 9-pin connector and pinout).&nbsp;

![hacks_psx-3459.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/969/medium640/hacks_psx-3459.jpg?1687295014)

Featured
### Pink and Purple Woven USB A to USB C Cable - 2 meters long

[Pink and Purple Woven USB A to USB C Cable - 2 meters long](https://www.adafruit.com/product/5044)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers and more.&nbsp; [If you want something just like it but for Micro B, we have a B...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5044)
[Related Guides to the Product](https://learn.adafruit.com/products/5044/guides)
![Angled shot of a pink/purple woven USB cable plugged into a laptop port and a small dev board.](https://cdn-shop.adafruit.com/640x480/5044-04.jpg)

Featured
### Pre-Cut Multi-Colored Heat Shrink Pack Kit - 280 pcs

[Pre-Cut Multi-Colored Heat Shrink Pack Kit - 280 pcs](https://www.adafruit.com/product/4559)
Heat shrink is the duct tape of electronics which we guess makes this heat shrink the colorful and exciting duct tape they sell&nbsp;at craft stores. &nbsp;This pack contains heat shrink tubes&nbsp;in five different colors - red, blue, aqua, yellow, and the classic Adafruit black.

Each...

In Stock
[Buy Now](https://www.adafruit.com/product/4559)
[Related Guides to the Product](https://learn.adafruit.com/products/4559/guides)
![Opened box full of short lengths of multi color heat shrink](https://cdn-shop.adafruit.com/640x480/4559-01.jpg)

# PlayStation Spinner Controller

## Wire the PlayStation Controller

![](https://cdn-learn.adafruit.com/assets/assets/000/121/927/medium800/hacks_psx-3456.jpg?1686966347)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/925/medium800/hacks_ps2_controller_fritz.jpg?1686955576)

PlayStation controllers use a nine-conductor, wired connector plug. Only six pins are necessary for our needs (we'll ignore the white VCC2 wire that's used for rumble motors, and the green ACK wire).

This is the wiring we'll use:

- **QT Py A0 - DAT** (data) **in** from PlayStation controller **brown wire**
- **QT Py A1 - CMD** (command) data **out** to PlayStation controller **orange wire**
- **QT Py A2 - ATT** &nbsp;(attention / chip select) **out** to PlayStation controller **yellow wire**
- **QT Py A3**  **- CLK** (clock) **out** to PlayStation controller **blue**  **wire**
- **QT Py GND** (ground) to PlayStation controller **black wire**
- **QT Py 3V** - **VCC** (power) **out** to PlayStation controller power **red wire**

![](https://cdn-learn.adafruit.com/assets/assets/000/121/926/medium800/hacks_psx_controller_qtpy_schematic.jpg?1686955608)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/928/medium800/hacks_psx-3457.jpg?1686966360)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/929/medium800/hacks_psx-3458.jpg?1686966367)

## Harvest the Connector Cable

Plug your controller into the extension cable to be sure you have the proper end selected. Then, cut the wire about 6 inches from that end.

Carefully remove about three inches of the outer insulation, making sure not to cut any of the wires.

![hacks_psx-3459.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/930/medium640/hacks_psx-3459.jpg?1686966409)

![hacks_psx-3460.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/931/medium640/hacks_psx-3460.jpg?1686966422)

![hacks_psx-3461.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/932/medium640/hacks_psx-3461.jpg?1686966432)

![hacks_psx-3462.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/933/medium640/hacks_psx-3462.jpg?1686966442)

Warning: 

## Wire the QT Py

Feed the wires through the QT Py holes as shown, according to the color coding shown in the Fritzing diagram (you can ignore white and green).

Trim the wires to a consistent length, leaving about 3/4" extra. Then strip insulation from the tips and back the wires out of the holes until the bare wire is centered in each hole, then solder them in place.

![hacks_psx-3474.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/972/medium640/hacks_psx-3474.jpg?1687295565)

![hacks_psx-3476.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/973/medium640/hacks_psx-3476.jpg?1687295595)

![hacks_psx-3477.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/974/medium640/hacks_psx-3477.jpg?1687295612)

![hacks_psx-3479.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/975/medium640/hacks_psx-3479.jpg?1687295627)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/976/medium800/hacks_psx-3478.jpg?1687295897)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/980/medium800/hacks_psx-3481.jpg?1687295922)

## Optional Heat Shrink Tubing

You can optionally tidy up the build with a bit of heat shrink tubing. Feeling really extra? Poke a small hole in the tubing to see the NeoPixel light up!

![hacks_psx-3483.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/993/medium640/hacks_psx-3483.jpg?1687296085)

![hacks_psx-3492.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/994/medium640/hacks_psx-3492.jpg?1687296095)

![hacks_psx-3493.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/995/medium640/hacks_psx-3493.jpg?1687296137)

![hacks_psx-3494.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/996/medium640/hacks_psx-3494.jpg?1687296111)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/997/medium800/hacks_psx-3501.jpg?1687296302)

![](https://cdn-learn.adafruit.com/assets/assets/000/121/988/medium800/hacks_psx-3519.jpg?1687296033)

## Hook Up

The adapter should work with any PSX or PS2 controller -- a PS2 DualShock controller is shown here connected to the QT Py adapter and USB.

![hacks_psx-3484.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/982/medium640/hacks_psx-3484.jpg?1687295944)

![hacks_psx-3485.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/983/medium640/hacks_psx-3485.jpg?1687295952)

![hacks_psx-3486.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/984/medium640/hacks_psx-3486.jpg?1687295960)

![hacks_psx-3521.jpg](https://cdn-learn.adafruit.com/assets/assets/000/121/998/medium640/hacks_psx-3521.jpg?1687296310)

# PlayStation Spinner Controller

## Installing CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython working on your board.

[Download the latest version of CircuitPython for the Raspberry Pi Pico from circuitpython.org](https://circuitpython.org/board/raspberry_pi_pico/)
 **Click the link above and download the latest UF2 file.**

Download and save it to your desktop (or wherever is handy).

![circuitpython_Cat_UF2_download.png](https://cdn-learn.adafruit.com/assets/assets/000/098/753/medium640/circuitpython_Cat_UF2_download.png?1611157944)

Start with your Pico unplugged from USB. Hold down the **BOOTSEL** button, and while continuing to hold it (don't let go!), plug the Pico into USB. **Continue to hold the BOOTSEL button until the RPI-RP2 drive appears!**

If the drive does not appear, unplug your Pico and go through the above process again.

A lot of people end up using charge-only USB cables and it is very frustrating! **So make sure you have a USB cable you know is good for data sync.**

![raspberry_pi_one_one_two.png](https://cdn-learn.adafruit.com/assets/assets/000/125/993/medium640/raspberry_pi_one_one_two.png?1699493528)

You will see a new disk drive appear called **RPI-RP2**.

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **RPI-RP2.**

![circuitpython_Cat_RPI-RP2_drive.png](https://cdn-learn.adafruit.com/assets/assets/000/098/756/medium640/circuitpython_Cat_RPI-RP2_drive.png?1611158210)

![circuitpython_Cat_drag_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/098/758/medium640/circuitpython_Cat_drag_UF2.png?1611158274)

The **RPI-RP2** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it, you're done! :)

![circuitpython_Cat_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/098/759/medium640/circuitpython_Cat_CIRCUITPY.png?1611158312)

## Flash Resetting UF2

If your Pico ever gets into a really _weird_ state and doesn't even show up as a disk drive when installing CircuitPython, try installing this 'nuke' UF2 which will do a 'deep clean' on your Flash Memory. You will lose all the files on the board, but at least you'll be able to revive it! After nuking, re-install CircuitPython

[flash_nuke.uf2](https://datasheets.raspberrypi.com/soft/flash_nuke.uf2)
# PlayStation Spinner Controller

## Code the PlayStation Spinner

## Text Editor

Adafruit recommends using the&nbsp; **Mu** &nbsp;editor for editing your CircuitPython code. You can get more info in&nbsp;[this guide](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

Alternatively, you can use any text editor that saves simple text files.

## Download the Project Bundle

Your project will use a specific set of CircuitPython libraries, and the&nbsp; **code.py** &nbsp;file. To get everything you need, click on the&nbsp; **Download Project Bundle** &nbsp;link below, and uncompress the .zip file.

Drag the contents of the uncompressed bundle directory onto your board's&nbsp; **CIRCUITPY** drive, replacing any existing files or directories with the same names, and adding any new ones that are necessary. The **CIRCUITPY** drive appears when you plug the QT Py into the computer via USB.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/PlayStation_Controller_Spinner/code.py

![circuitpy](https://adafruit.github.io/Adafruit_Learning_System_Guides/PlayStation_Controller_Spinner.png )

## How It Works

The code uses the `ps2controller` library to interpret the PlayStation controller messages, then the `adafruit_hid` library is used to send USB keyboard commands and mouse clicks.

### Libraries

First, the necessary libraries and modules are imported.

```auto
import time
import board
import usb_hid
import neopixel
from adafruit_hid.keycode import Keycode
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.mouse import Mouse
from ps2controller import PS2Controller
```

### NeoPixel Setup

The on-board NeoPixel is set up next to be used as a status indicator -- amber during boot up and blue when a PSX/PS2 controller has been successfully connected.

```auto
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)
led.fill(0x331000)  # amber while we wait for controller to connect
```

### Mouse and Keyboard Setup

Next, we create instances of `Mouse`, `Keyboard`, and `KeyboardLayoutUS`.

```auto
mouse = Mouse(usb_hid.devices)

keyboard = Keyboard(usb_hid.devices)
layout = KeyboardLayoutUS(keyboard)
```

### PS2Controller

We'll created an object called `psx` that is an instance of the `PS2Controller` with the necessary pin configuration to use it on the **QT Py**. After the controller is set up the NeoPixel is set to blue.

```auto
psx = PS2Controller(
    dat=board.A0,
    cmd=board.A1,
    att=board.A2,
    clk=board.A3
)

led.fill(0x0010ee)
```

### Variables

A boolean variable called `circle_held` is used to hold the state of the spinner -- while the **O** (circle) button is held (meaning the spinner is spinning) this variable is `True` and the rapid mouse button spamming will occur. When the spinner stops the mouse button stops spamming.

The `spam_speed` variable is used to adjust the mouse-click rate.

```auto
circle_held = False
spam_speed = 0.001
```

### Buttonmap

The `buttonmap` dictionary is defined to map the controller button names to USB HID keycodes or mouse-clicks. The first item in each key is a `0` or `1` to indicate if keycodes or mouse events are sent, while the second item is the specific keycode or mouse event.

```auto
buttonmap = {
            ("SELECT"): (0, Keycode.SPACEBAR),
            ("START"): (0, Keycode.X),
            ("UP"): (0, Keycode.W),
            ("DOWN"): (0, Keycode.S),
            ("RIGHT"): (0, Keycode.D),
            ("LEFT"): (0, Keycode.A),
            ("L3"): (0, Keycode.V),
            ("R3"): (0, Keycode.B),
            ("L2"): (0, Keycode.R),
            ("R2"): (0, Keycode.T),
            ("L1"): (0, Keycode.F),
            ("R1"): (0, Keycode.G),
            ("TRIANGLE"): (0, Keycode.I),
            ("CIRCLE"): (1, Mouse.LEFT_BUTTON),
            ("CROSS"): (0, Keycode.K),
            ("SQUARE"): (0, Keycode.L),
}
```

### Main Loop

The main loop of the program first checks for any PSX controller events with `psx.update()`.

Each controller event is checked to see if it should trigger a keycode or mouse event.

The events are then sent as per the `buttonmap` mappings.

Keycodes are pressed and then released along with their corresponding buttons, while the **O** key that the spinner sends is treated specially -- it rapidly clicks the left mouse button, making it perfect for clicker games!

```auto
while True:
    events = psx.update()
    if events:
        print(events)
        for event in events:
            if buttonmap[event.name][0] == 0:  # regular button
                if event.pressed:
                    keyboard.press(buttonmap[event.name][1])
                if event.released:
                    keyboard.release(buttonmap[event.name][1])

            if buttonmap[event.name][0] == 1:  # mouse button
                if event.pressed:
                    circle_held = True
                if event.released:
                    circle_held = False

    if circle_held:  # spam the mouse click
        mouse.press(buttonmap["CIRCLE"][1])
        mouse.release_all()
        time.sleep(spam_speed)
```

# PlayStation Spinner Controller

## Use the Controller

![](https://cdn-learn.adafruit.com/assets/assets/000/122/003/medium800/hacks_IMG_3569.jpg?1687306424)

https://youtu.be/4LS5t62OTvU

The above video shows how to use the controller -- simply plug the controller into the adapter, then plug the QT Py USB into the computer or mobile device USB host.

Spinning the spinner sends two bursts of variable mouse clicks, as shown in the video. Pressing any other buttons sends USB HID keycodes, which can be customized for your needs in the code.


## Guide Products

### 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)

In Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)
### PlayStation Extension Cable - Compatible with PS1 and 2

[PlayStation Extension Cable - Compatible with PS1 and 2](https://www.adafruit.com/product/5773)
Ostensibly this extension cord was originally designed to allow PlayStation game players to be able to sit across the room from their game system, but what we are using it for is to connect to PS controllers and accessories without soldering directly to cables or cutting the connectors off....

In Stock
[Buy Now](https://www.adafruit.com/product/5773)
[Related Guides to the Product](https://learn.adafruit.com/products/5773/guides)
### Pink and Purple Woven USB A to USB C Cable - 2 meters long

[Pink and Purple Woven USB A to USB C Cable - 2 meters long](https://www.adafruit.com/product/5044)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers and more.&nbsp; [If you want something just like it but for Micro B, we have a B...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5044)
[Related Guides to the Product](https://learn.adafruit.com/products/5044/guides)
### Pre-Cut Multi-Colored Heat Shrink Pack Kit - 280 pcs

[Pre-Cut Multi-Colored Heat Shrink Pack Kit - 280 pcs](https://www.adafruit.com/product/4559)
Heat shrink is the duct tape of electronics which we guess makes this heat shrink the colorful and exciting duct tape they sell&nbsp;at craft stores. &nbsp;This pack contains heat shrink tubes&nbsp;in five different colors - red, blue, aqua, yellow, and the classic Adafruit black.

Each...

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

## Related Guides

- [Adafruit QT Py RP2040](https://learn.adafruit.com/adafruit-qt-py-2040.md)
- [ESP32-S3 BLE RS-232 Controller](https://learn.adafruit.com/esp32-s3-ble-rs232-controller.md)
- [MIDI for Makers](https://learn.adafruit.com/midi-for-makers.md)
- [DOOM on Fruit Jam](https://learn.adafruit.com/doom-on-fruit-jam.md)
- [Feather RP2040 DVI CircuitPython Day 2024 Countdown Clock](https://learn.adafruit.com/feather-rp2040-dvi-circuitpython-day-2024-countdown-clock.md)
- [16x16 NeoPixel Matrix Square Pixel Display](https://learn.adafruit.com/16x16-neopixel-matrix-square-pixel-display.md)
- [Darth Faders](https://learn.adafruit.com/darth-faders.md)
- [Halloween Neon LED Signs](https://learn.adafruit.com/halloween-neon-led-signs.md)
- [DIY USB Cable Aviation Connector Retro-Fit](https://learn.adafruit.com/aviation-connector-diy-usb-cables.md)
- [Talking HAL 9000 with RP2040 Prop Maker Feather](https://learn.adafruit.com/hal-9000-rp2040-prop-maker.md)
- [Fruit Jam Video Music](https://learn.adafruit.com/fruit-jam-video-music.md)
- [NeoKey Emoji Keyboard](https://learn.adafruit.com/neokey-emoji-keyboard.md)
- [Digital Clock with CircuitPython](https://learn.adafruit.com/digital-clock-with-circuitpython.md)
- [IBM PC Keyboard to USB HID with CircuitPython](https://learn.adafruit.com/ibm-pc-keyboard-to-usb-hid-with-circuitpython.md)
- [MIDI Controlled Robot Lyre with CircuitPython](https://learn.adafruit.com/midi-controlled-robot-lyre-with-circuitpython.md)
- [FunHouse Mail Slot Detector](https://learn.adafruit.com/funhouse-mail-slot-detector.md)
