# Adafruit Joy Bonnet for Raspberry Pi

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/040/402/medium800thumb/gaming_3464_GIF.jpg?1490218337)

Pocket-sized fun is the name of this game, with the Joy Bonnet - our most fun Bonnet ever (no we didn't even think that was possible, either!) This Bonnet fits perfectly on top of your Raspberry Pi Zero (any kind) and gives you adorable hand-held arcade controls. Once you install our script onto your Pi, the controls will act like a keyboard, for easy use with any emulator or media player.

![](https://cdn-learn.adafruit.com/assets/assets/000/040/397/medium800/gaming_3464_top_ORIG.jpg?1490217893)

Personally, we found this Bonnet to work best with RetroPie/EmulationStation. On a Pi Zero we could emulate NES and MAME game (our favorites!) but other emulators that don't require more than 1GHz speeds will work OK too, e.g. a N64 emulator won't work, it needs way more power!

![](https://cdn-learn.adafruit.com/assets/assets/000/040/400/medium800/gaming_3464_quarter_ORIG.jpg?1490218033)

Best of all, this Bonnet is fully assembled - no soldering at all is required. You may need to solder headers onto your Pi Zero (or use press-fit headers) but once that's done you're ready to rock. In theory you could also use this with one of the full-size Pi models, but it wouldn't be very hand-held

![](https://cdn-learn.adafruit.com/assets/assets/000/040/399/medium800/gaming_3464_iso_demo_ORIG.jpg?1490218008)

Since you'll likely grip the Pi during play, we strongly recommend a comfortable enclosure to go along with it! The Adafruit Pi Zero case works well and is nice and rounded for easy holding

### Adafruit Raspberry Pi Zero Case

[Adafruit Raspberry Pi Zero Case](https://www.adafruit.com/product/3252)
This is a basic, classic **Pi Zero enclosure** with a black base and a clear top.&nbsp;The case is as minimal as it gets, coming in just two pieces of polycarbonate that snap snugly together. This case will keep your&nbsp;Pi Zero safe and secure while also looking super sleek. You...

In Stock
[Buy Now](https://www.adafruit.com/product/3252)
[Related Guides to the Product](https://learn.adafruit.com/products/3252/guides)
![Angled shot of a rectangular black and clear acrylic case.](https://cdn-shop.adafruit.com/640x480/3252-00.jpg)

[Friendly forum-member cvadillo suggests](https://forums.adafruit.com/viewtopic.php?f=50&t=123637&p=636123#p618773) slipping the extra piece of plastic underneath the bonnet to support it

![adafruit_products_file.jpg](https://cdn-learn.adafruit.com/assets/assets/000/048/987/medium640/adafruit_products_file.jpg?1512752376)

A Mini HDMI cable will also make it easy to plug-and-play into your HDMI screen

### Mini HDMI to HDMI Cable - 5 feet

[Mini HDMI to HDMI Cable - 5 feet](https://www.adafruit.com/product/2775)
Connect a device with a&nbsp;Mini HDMI port to a regular sized HDMI port together with this basic HDMI cable. It has nice molded grips for easy installation, and is 1.5 meter long (about 5 feet). [Perfect for use with your new Raspberry Pi...](https://www.adafruit.com/pizero)

Out of Stock
[Buy Now](https://www.adafruit.com/product/2775)
[Related Guides to the Product](https://learn.adafruit.com/products/2775/guides)
![Coiled bundle of HDMI extension cable.](https://cdn-shop.adafruit.com/640x480/2775-00.jpg)

# Adafruit Joy Bonnet for Raspberry Pi

## Install & Use

# Software

Software installation for the Joy&nbsp;Bonnet requires an internet connection. That’s a frequent topic already covered in other Pi getting-started guides, so we’ll assume here that your Pi is already booted and networked, running Raspbian or a gaming-ready OS like RetroPie. (RetroPie is what we use, and recommend!) [RetroPie has a nice First Installation guide](https://retropie.org.uk/docs/First-Installation/)

You can set up the controls however you like, its easy to change them up later. Just get logged into RetroPie, and setup WiFi. Then get into a terminal either on the HDMI console or by ssh'ing in.

[You may find this easiest if&nbsp; **ssh** &nbsp;is enabled on the Pi, and then log in with a terminal app.](https://www.raspberrypi.org/documentation/remote-access/ssh/)This lets you&nbsp; **copy-and-paste** &nbsp;the commands that follow, as they’re very exact about spelling.

# Install!

Enter the following few lines to install support for the buttons and joystick:

```terminal
cd ~
sudo apt-get install python3-pip
sudo pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/joy-bonnet.py
sudo python3 joy-bonnet.py
```

When run, this script will offer a couple of options:

- **Disable overscan?** &nbsp;If you answer “Y” this removes the black border around the screen (common on HDMI monitors). Takes effect on next boot.
- **Install gpio-halt utility?** &nbsp;Linux-based systems like the Raspberry Pi don’t like it when you just switch off power…there’s a specific shutdown process, else the SD card may get corrupted. The gpio-halt tool lets you add one more button between ground and any unused GPIO pin to initiate an orderly shutdown. Gaming OSes like RetroPie already include a shutdown command among their menu options, so you probably do&nbsp; **not** need this, unless you want a dedicated button for it.

When the script finishes you’ll be asked whether to reboot. Answer “N” if you plan on installing&nbsp;other software. Either way, **sudo reboot** when done to get the joy bonnet software activated!

![](https://cdn-learn.adafruit.com/assets/assets/000/040/385/medium800/gaming_reboot.png?1490208789)

That's it! The script to generate keycodes is now installed and will be run every time the Pi boots

Once RetroPie has restarted, go to the **MENU** &nbsp; and step down to **CONFIGURE INPUT** and select it to re-start the input configuration. The left joystick can be used for up/down/left/right. The right buttons are A B X Y. Middle buttons are Select and Start as labeled. Then you get two more buttons you can set up as left/right shoulder or trigger buttons.

Note that pressing Select+Start will quit out of games, other than that the controls are used in the emulators by generating 'key presses' - see below for how to change the keypresses!

![](https://cdn-learn.adafruit.com/assets/assets/000/040/386/medium800/gaming_0263b9c8-3cef-11e5-922f-42f790f3be91.png?1490208963)

Although the Joy Bonnet has an analog stick, the software installed above makes this act like a digital 4-way stick emitting key presses. This is on purpose and by design, as Retropie on a single-stick controller like this expects digital inputs.

# Advanced Usage

**If you need to change the key assignments:** &nbsp;edit the file&nbsp; **/boot/joyBonnet.py&nbsp;** say with&nbsp;`sudo nano /boot/joyBonnet.py`

Near the top of the code you’ll see this table:

![](https://cdn-learn.adafruit.com/assets/assets/000/040/387/medium800/gaming_keytable.png?1490209051)

'#' lines are human comments and do nothing for the code. The first eight&nbsp;actual elements in the table correspond to the button inputs, while the last four are the joystick directions.

# Adafruit Joy Bonnet for Raspberry Pi

## Downloads

# Source Code

- [Joy Bonnet installer](https://github.com/adafruit/Raspberry-Pi-Installer-Scripts) and [key-press python script](https://github.com/adafruit/Adafruit-Retrogame) available on github!

# Files

- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-Joy-Bonnet-PCB)

# Schematic
![](https://cdn-learn.adafruit.com/assets/assets/000/040/388/medium800/gaming_schem.png?1490209545)


## Featured Products

### Adafruit Joy Bonnet for Raspberry Pi

[Adafruit Joy Bonnet for Raspberry Pi](https://www.adafruit.com/product/3464)
Pocket-sized fun is the name of this game, with the **Joy Bonnet** &nbsp;–&nbsp;our most fun Bonnet ever (no, we didn't even think that was possible, either!). This Bonnet fits perfectly on top of your Raspberry Pi Zero (any kind) and gives you adorable hand-held arcade...

In Stock
[Buy Now](https://www.adafruit.com/product/3464)
[Related Guides to the Product](https://learn.adafruit.com/products/3464/guides)
### Joy Bonnet Pack for Raspberry Pi Zero - Includes Pi Zero W

[Joy Bonnet Pack for Raspberry Pi Zero - Includes Pi Zero W](https://www.adafruit.com/product/3205)
The **Joy Bonnet Pack for Raspberry Pi Zero W** sets you up with the [Pi Zero W](https://www.adafruit.com/product/3400), and our [Joy Bonnet](https://www.adafruit.com/product/3464) **&nbsp;-&nbsp;** our most fun Bonnet ever!&nbsp;This Bonnet fits...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/3205)
[Related Guides to the Product](https://learn.adafruit.com/products/3205/guides)
### Adafruit Raspberry Pi Zero Case

[Adafruit Raspberry Pi Zero Case](https://www.adafruit.com/product/3252)
This is a basic, classic **Pi Zero enclosure** with a black base and a clear top.&nbsp;The case is as minimal as it gets, coming in just two pieces of polycarbonate that snap snugly together. This case will keep your&nbsp;Pi Zero safe and secure while also looking super sleek. You...

In Stock
[Buy Now](https://www.adafruit.com/product/3252)
[Related Guides to the Product](https://learn.adafruit.com/products/3252/guides)
### Mini HDMI to HDMI Cable - 5 feet

[Mini HDMI to HDMI Cable - 5 feet](https://www.adafruit.com/product/2775)
Connect a device with a&nbsp;Mini HDMI port to a regular sized HDMI port together with this basic HDMI cable. It has nice molded grips for easy installation, and is 1.5 meter long (about 5 feet). [Perfect for use with your new Raspberry Pi...](https://www.adafruit.com/pizero)

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

[Raspberry Pi Zero](https://www.adafruit.com/product/2818)
Note: Due to popular demand, there might be some delay in shipping products containing Pi Zero!

At first glance, the Pi Zero isn't much. &nbsp;It just looks like a slimmed down version of the Raspberry Pi we know and love. &nbsp;But when we started to think of the possibilities...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2818)
[Related Guides to the Product](https://learn.adafruit.com/products/2818/guides)
### Raspberry Pi Zero W

[Raspberry Pi Zero W](https://www.adafruit.com/product/3400)
If you didn't think that the Raspberry Pi Zero could possibly get any better, then boy do we have a pleasant surprise for you!&nbsp;The new **Raspberry Pi Zero W** offers all the benefits of the Pi Zero v1.3, but with one big difference – **built-in...**

In Stock
[Buy Now](https://www.adafruit.com/product/3400)
[Related Guides to the Product](https://learn.adafruit.com/products/3400/guides)
### Raspberry Pi Zero W Basic Pack - Includes Pi Zero W

[Raspberry Pi Zero W Basic Pack - Includes Pi Zero W](https://www.adafruit.com/product/3409)
Remember those cereal commercials that would always say,&nbsp;"part of a complete breakfast"? Well the Pi Zero's a lot like that bowl of cereal - while it's great&nbsp;on its own, you&nbsp;need a lot of accessories to make it a complete meal.

The **Pi Zero W...**

Out of Stock
[Buy Now](https://www.adafruit.com/product/3409)
[Related Guides to the Product](https://learn.adafruit.com/products/3409/guides)
### Raspberry Pi Zero W Budget Pack - Includes Pi Zero W

[Raspberry Pi Zero W Budget Pack - Includes Pi Zero W](https://www.adafruit.com/product/3410)
Remember those cereal commercials that would always say,&nbsp;"part of a complete breakfast"? Well the Pi Zero's a lot like that bowl of cereal - while it's great&nbsp;on its own, you&nbsp;need a lot of accessories to make it a complete meal.

The **Pi Zero W...**

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

## Related Guides

- [reef-pi Guide 1: Setup and Demonstration](https://learn.adafruit.com/reef-pi-installation-and-configuration.md)
- [Raspberry Pi Zero Headless Quick Start](https://learn.adafruit.com/raspberry-pi-zero-creation.md)
- [NES Cart RetroPie Game Console](https://learn.adafruit.com/nes-cart-retropie.md)
- [Read-Only Raspberry Pi](https://learn.adafruit.com/read-only-raspberry-pi.md)
- [CNC Joy Bonnet Case](https://learn.adafruit.com/joy-bonnet-case.md)
- [Pi Hole Ad Blocker with Pi Zero W](https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w.md)
- [Adafruit CharliePlex LED Matrix Bonnet](https://learn.adafruit.com/adafruit-charlieplex-bonnet.md)
- [MakeCode Arcade with Raspberry Pi Zero](https://learn.adafruit.com/makecode-arcade-with-raspberry-pi-zero.md)
- [Haunted Portrait](https://learn.adafruit.com/haunted-portrait.md)
- [AdaBox 005](https://learn.adafruit.com/adabox005.md)
- [Turning your Raspberry Pi Zero into a USB Gadget](https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget.md)
- [Adafruit PiUART - USB Console and Power Add-on for Raspberry Pi](https://learn.adafruit.com/adafruit-piuart-usb-console-and-power-add-on-for-raspberry-pi.md)
- [Adafruit MONSTER M4SK](https://learn.adafruit.com/adafruit-monster-m4sk-eyes.md)
- [Super Nintendo USB Controller](https://learn.adafruit.com/super-nintendo-usb-controller.md)
- [Re-MakeCode the Classics: Arkanoid](https://learn.adafruit.com/re-makecode-the-classics-arkanoid.md)
