# Breakout Game on the Metro RP2350 and Fruit Jam

## Overview

![An HDMI color monitor showing a row of multicolor bricks and a paddle at the bottom to play the game breakout with a Metro RP2350 in the bottom foreground](https://cdn-learn.adafruit.com/assets/assets/000/135/540/medium800/raspberry_pi_20250227_194058.jpg?1754938530 )

This guide presents the classic video game Breakout which uses an HDMI monitor for video out and a computer keyboard connected via USB for game control. Sound effects play for certain game functions via a speaker.

The Adafruit Metro RP2350 contains the RP2350B in a familiar "Arduino Uno" form factor with many peripherals included on the board. These include an HSTX connector that, when connected to a DVI breakout board, can output video compatible with modern HDMI monitors.

The board also has pins for a USB Host port to connect a keyboard or game controller.

![The Adafruit Metro RP2350 board](https://cdn-learn.adafruit.com/assets/assets/000/135/539/medium640/gaming_raspberry_pi_Metro.png?1741105333)

The Adafruit Fruit Jam is an "all-in-one" board with the same processor as the Metro RP2350. It has the DVI video connector on the board (ready to go). It also has two USB host ports for plugging in peripherals.

The Fruit Jam has a built-in DAC and speaker capability for sound.

![Adafruit Fruit Jam mini-computer circuit board](https://cdn-learn.adafruit.com/assets/assets/000/138/782/medium640/gaming_aa.jpg?1754938584)

![An animated picture of gameplay for the Breakout game using a keyboard to move the cursor on the screen to bounce a ball and knock out colored bricks on screen](https://cdn-learn.adafruit.com/assets/assets/000/135/651/medium800thumb/gaming_Gameplay_%28short%29.jpg?1754938819 )

## Parts
Metro RP2350 version:

### Adafruit Metro RP2350

[Adafruit Metro RP2350](https://www.adafruit.com/product/6003)
Choo! Choo! This is the RP2350 Metro Line, making all station stops at "Dual Cortex M33 mountain", "528K RAM round-about" and "16 Megabytes of Flash town". This train is piled high with hardware that complements the Raspberry Pi RP2350 chip to make it an excellent...

In Stock
[Buy Now](https://www.adafruit.com/product/6003)
[Related Guides to the Product](https://learn.adafruit.com/products/6003/guides)
![Angled shot of black, credit card-sized microcontroller with stacking headers.](https://cdn-shop.adafruit.com/640x480/6003-06.jpg)

### USB Type A Jack Breakout Cable with Premium Female Jumpers

[USB Type A Jack Breakout Cable with Premium Female Jumpers](https://www.adafruit.com/product/4449)
If you'd like to connect a USB-host-capable chip to your USB peripheral, this cable will make the task very simple.&nbsp; **There is no converter chip in this cable!** &nbsp;It's basically a plain USB cable that's cut in half and with jumper sockets on the power and data...

In Stock
[Buy Now](https://www.adafruit.com/product/4449)
[Related Guides to the Product](https://learn.adafruit.com/products/4449/guides)
![USB Type A Socket Breakout Cable with Premium Female Jumpers](https://cdn-shop.adafruit.com/640x480/4449-02.jpg)

### Solderless Press-Fit Male Pin Header - 2.54mm / 0.1" Pitch

[Solderless Press-Fit Male Pin Header - 2.54mm / 0.1" Pitch](https://www.adafruit.com/product/5938)
If your soldering isn't quite up to scratch, or you yet don't own a soldering iron, then these nifty **0.1"/2.54mm&nbsp;standard pitch&nbsp;press-fit headers** might be just what you need.&nbsp;

**Absolutely no soldering required!** All that's...

In Stock
[Buy Now](https://www.adafruit.com/product/5938)
[Related Guides to the Product](https://learn.adafruit.com/products/5938/guides)
![Angled shot of press-fit header.](https://cdn-shop.adafruit.com/640x480/5938-00.jpg)

### Adafruit RP2350 22-pin FPC HSTX to DVI Adapter for HDMI Displays

[Adafruit RP2350 22-pin FPC HSTX to DVI Adapter for HDMI Displays](https://www.adafruit.com/product/6055)
You may have noticed that our [RP2350 Feather](https://www.adafruit.com/product/6000) has an FPC output connector on the end&nbsp;for accessing the HSTX (High Speed Transmission)&nbsp;peripheral. This new capability, not available on the RP2040, is specifically designed to allow the...

In Stock
[Buy Now](https://www.adafruit.com/product/6055)
[Related Guides to the Product](https://learn.adafruit.com/products/6055/guides)
![black, square-shaped breakout board with DVI and 22-pin FPC connectors connected to a black, rectangular microcontroller.](https://cdn-shop.adafruit.com/640x480/6055-01.jpg)

### 22-pin 0.5mm pitch FPC Flex Cable for DSI CSI or HSTX - 20cm

[22-pin 0.5mm pitch FPC Flex Cable for DSI CSI or HSTX - 20cm](https://www.adafruit.com/product/6036)
Connect this to that when a 22-pin FPC connector is needed. This 20 cm long cable is made of a flexible PCB. It's A-B style, meaning that pin one on one side will match with pin one on the other. How handy!

[We're stocking this to...](https://www.adafruit.com/category/360)

In Stock
[Buy Now](https://www.adafruit.com/product/6036)
[Related Guides to the Product](https://learn.adafruit.com/products/6036/guides)
![Angled shot of 20cm long, 22-pin FPC cable.](https://cdn-shop.adafruit.com/640x480/6036-00.jpg)

### Piezo Buzzer

[Piezo Buzzer](https://www.adafruit.com/product/160)
Piezo buzzers are used for making beeps, tones and alerts. This one is petite but loud! Drive it with 3-30V peak-to-peak square wave. To use, connect one pin to ground (either one) and the other pin to a square wave out from a timer or microcontroller. For the loudest tones, stay around 4 KHz,...

In Stock
[Buy Now](https://www.adafruit.com/product/160)
[Related Guides to the Product](https://learn.adafruit.com/products/160/guides)
![Bread-board friendly Piezo Buzzer](https://cdn-shop.adafruit.com/640x480/160-01.jpg)

--- or if using the Fruit Jam --

### Adafruit Fruit Jam - Mini RP2350 Computer

[Adafruit Fruit Jam - Mini RP2350 Computer](https://www.adafruit.com/product/6200)
We were catching up on a recent [hackaday hackchat with eben upton](https://hackaday.io/event/202122-raspberry-pi-hack-chat-with-eben-upton)&nbsp;and learned some fun facts: such as the DVI hack for the RP2040 was inspired by <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/6200)
[Related Guides to the Product](https://learn.adafruit.com/products/6200/guides)
![Angled shot of assembled mini computer PCB with plate.](https://cdn-shop.adafruit.com/640x480/6200-10.jpg)

Either the Metro or the Fruit Jam will need an HDMI cable to connect between the board and your display.

### HDMI Cable - 1 meter

[HDMI Cable - 1 meter](https://www.adafruit.com/product/608)
Connect two HDMI devices together with this basic HDMI cable. It has nice molded grips for easy installation, and is 1 meter long (about 3 feet). This is a HDMI 1.3 cable.

We're now stocking a very fancy Official Raspberry Pi cable with overmolding and a Pi logo. Please note...

In Stock
[Buy Now](https://www.adafruit.com/product/608)
[Related Guides to the Product](https://learn.adafruit.com/products/608/guides)
![Official Raspberry Pi HDMI Cable - 1 meter](https://cdn-shop.adafruit.com/640x480/608-03.jpg)

- and -

You'll need a USB cable to hook to your PC for either solution. If your computer has a USB C port, you'll want the USB C to USB C cable.

### Part: USB A to USB C Cable
quantity: 1
Approx 1 meter / 3 ft long
[USB A to USB C Cable](https://www.adafruit.com/product/4474)

- or -

### Part: USB C to USB C Cable
quantity: 1
USB 3.1 Gen 4 with E-Mark - 1 meter long
[USB C to USB C Cable](https://www.adafruit.com/product/4199)

It's suggested you use an HDMI display you have around, such as a computer monitor or television. If you'd like to get a dedicated monitor:

### 7" Display 1280x800 (720p) IPS + Speakers - HDMI/VGA/NTSC/PAL

[7" Display 1280x800 (720p) IPS + Speakers - HDMI/VGA/NTSC/PAL](https://www.adafruit.com/product/1667)
Yes, this is an adorable small HDMI television with incredibly high resolution **and built in 3W stereo speakers**! We tried to get the smallest possible HDMI/VGA display with high-res, high-contrast visibility. The visible display measures only 7" (17.8cm) diagonal, and the TFT comes...

In Stock
[Buy Now](https://www.adafruit.com/product/1667)
[Related Guides to the Product](https://learn.adafruit.com/products/1667/guides)
![Front view of assembled and powered on HDMI 4 Pi - 7" Display. The monitor displays a desktop background with a raspberry logo.](https://cdn-shop.adafruit.com/640x480/1667-00.jpg)

# Breakout Game on the Metro RP2350 and Fruit Jam

## Preparing the Metro RP2350

The USB Host port is the only part of this project that required soldering and only if you use standard header pins. If you use the [Solderless Press-Fit Male Pin Header](https://www.adafruit.com/product/5938) in the Parts list, soldering may not be required if they are installed correctly.

The USB Host pin connections are highlighted on the Metro image to the left. You will need a small piece of 0.1 inch male header, with 4 pins, to fit the holes.

You can cut header with diagonal cutters or break them with pliers or even your fingers. Just be sure to wear eye protection as they can fly when cut.&nbsp;

![The Metro RP2350 board with the USB Host connection highlighted](https://cdn-learn.adafruit.com/assets/assets/000/135/532/medium640/raspberry_pi_adafruit_products_pinouts_usbhost_highlight.png?1740704493)

![Male header strip, full, "hammer" in](https://cdn-learn.adafruit.com/assets/assets/000/136/240/medium640/gaming_four.png?1744210071)

Put the short end of the header into the holes in the Metro marked USB Host.&nbsp;

If you are using solderless header then they are press fit into the holes. You might need some pressure to get them in. While they are designed to make electrical contact, you might want to solder them to be sure.

If using standard header, secure them with putty, blutack, tape, etc.

Turn the Metro over and you should see the header barely poking out of the bottom of the board. If the pins stick through a great deal you may have the header pins upside down, double check the short end is sticking into the board.

Solder the 4 pin "nubbins" to the board.

![A Hakko soldering iron, a roll of solder and a Metro RP2350 board](https://cdn-learn.adafruit.com/assets/assets/000/135/534/medium640/raspberry_pi_20250226_110701.jpg?1740705385)

![The back of the Metro RP2350 board showing the short end of the header pins sticking through the board](https://cdn-learn.adafruit.com/assets/assets/000/135/535/medium640/raspberry_pi_20250226_110712.jpg?1740705653)

![The Metro back off the PC board with the pins soldered](https://cdn-learn.adafruit.com/assets/assets/000/135/536/medium640/gaming_raspberry_pi_20250226_110952.jpg?1754938894)

Turn the board over and remove the material securing the pins. Now there is a new 4-pin header.&nbsp;

Get the USB Host cable and wire as follows:

**GRD** to **Black**

**D+** to **Green**

**D-** to **White**

**5V** to **Red**

![The Metro, right side up, with the USB Host pins installed](https://cdn-learn.adafruit.com/assets/assets/000/135/537/medium640/raspberry_pi_20250226_111019.jpg?1740705869)

![An Adafruit Metro RP2350 board with a USB Host port cable assembly attached in the middle and an HSTX cable on the left extending to an HSTX to HDMI breakout board](https://cdn-learn.adafruit.com/assets/assets/000/135/538/medium800/raspberry_pi_20250227_192553.jpg?1754939038 )

## HSTX Connection to DVI
![An Adafruit Metro RP2350 board with an HSTX cable on the left extending to an HSTX to HDMI breakout board](https://cdn-learn.adafruit.com/assets/assets/000/135/597/medium800/gaming_hstx.png?1754939026 )

Get the HSTX cable. Any length Adafruit sells is fine. CAREFULLY lift the dark grey bar up on the Metro, insert the cable silver side down, blue side up, then put the bar CAREFULLY down, ensuring it locks. If it feels like it doesn't want to go, do not force it.

Do the same with the other end and the DVI breakout. Note that the DVI breakout will be inverted/upside down when compared to the Metro - this is normal for these boards and the Adafruit cables.

## Piezo Speaker (optional)
Games always are better with some sound. This project uses a small Piezo speaker pressed to the headers.

### Piezo Buzzer

[Piezo Buzzer](https://www.adafruit.com/product/160)
Piezo buzzers are used for making beeps, tones and alerts. This one is petite but loud! Drive it with 3-30V peak-to-peak square wave. To use, connect one pin to ground (either one) and the other pin to a square wave out from a timer or microcontroller. For the loudest tones, stay around 4 KHz,...

In Stock
[Buy Now](https://www.adafruit.com/product/160)
[Related Guides to the Product](https://learn.adafruit.com/products/160/guides)
![Bread-board friendly Piezo Buzzer](https://cdn-shop.adafruit.com/640x480/160-01.jpg)

Connect the Piezo leads into pins 23 and GND, which are adjacent, on the female header pins. No soldering is needed.

![An Adafruit Metro RP2350 with a Piezo Speaker inserted into the top header pins 23 and GND](https://cdn-learn.adafruit.com/assets/assets/000/135/596/medium640/gaming_20250303_133151.jpg?1741030621)

# Breakout Game on the Metro RP2350 and Fruit Jam

## CircuitPython for the Metro

[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 running on your board.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_metro_rp2350/)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/655/medium640/install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg?1618943202)

![](https://cdn-learn.adafruit.com/assets/assets/000/135/292/medium800/adafruit_products_boot_reset_btn_highlights.png?1739467365)

To enter the bootloader, hold down the **BOOT/**** BOOTSEL button**(highlighted in red above), and while continuing to hold it (don't let go!), press and release the**reset button**(highlighted in red or blue above).&nbsp;**Continue to hold the BOOT/BOOTSEL button until the RP2350 drive appears!**

If the drive does not appear, release all the buttons, and then repeat the process above.

You can also start with your board unplugged from USB, press and hold the BOOTSEL button (highlighted in red above), continue to hold it while plugging it into USB, and wait for the drive to appear before releasing the button.

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

You will see a new disk drive appear called **RP2350**.

&nbsp;

Drag the **adafruit-circuitpython-_boardname_-_language_-_version_.uf2** file to **RP2350.**

![install_circuitpython_on_rp2350_Screenshot_2024-09-11_111518.png](https://cdn-learn.adafruit.com/assets/assets/000/132/253/medium640/install_circuitpython_on_rp2350_Screenshot_2024-09-11_111518.png?1726067809)

![install_circuitpython_on_rp2350_Screenshot_2024-09-11_111742.png](https://cdn-learn.adafruit.com/assets/assets/000/132/254/medium640/install_circuitpython_on_rp2350_Screenshot_2024-09-11_111742.png?1726067866)

The **RP2350** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

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

![install_circuitpython_on_rp2350_Screenshot_2024-09-11_111843.png](https://cdn-learn.adafruit.com/assets/assets/000/132/255/medium640/install_circuitpython_on_rp2350_Screenshot_2024-09-11_111843.png?1726067932)

## Safe Mode

You want to edit your **code.py** or modify the files on your **CIRCUITPY** drive, but find that you can't. Perhaps your board has gotten into a state where **CIRCUITPY** is read-only. You may have turned off the **CIRCUITPY** drive altogether. Whatever the reason, safe mode can help.

Safe mode in CircuitPython does not run any user code on startup, and disables auto-reload. This means a few things. First, safe mode _bypasses any code in_ **boot.py** (where you can set **CIRCUITPY** read-only or turn it off completely). Second, _it does not run the code in_ **code.py**. And finally, _it does not automatically soft-reload when data is written to the_ **CIRCUITPY** _drive_.

Therefore, whatever you may have done to put your board in a non-interactive state, safe mode gives you the opportunity to correct it without losing all of the data on the **CIRCUITPY** drive.

### Entering Safe Mode
To enter safe mode when using CircuitPython, plug in your board or hit reset (highlighted in red above). Immediately after the board starts up or resets, it waits 1000ms. On some boards, the onboard status LED (highlighted in green above) will blink yellow during that time. If you press reset during that 1000ms, the board will start up in safe mode. It can be difficult to react to the yellow LED, so you may want to think of it simply as a slow double click of the reset button. (Remember, a fast double click of reset enters the bootloader.)

### In Safe Mode

If you successfully enter safe mode on CircuitPython, the LED will intermittently blink yellow three times.

If you connect to the serial console, you'll find the following message.

```terminal
Auto-reload is off.
Running in safe mode! Not running saved code.

CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.
```

You can now edit the contents of the **CIRCUITPY** drive. Remember, _your code will not run until you press the reset button, or unplug and plug in your board, to get out of safe mode._

## Flash Resetting UF2

If your board ever gets into a really _weird_ state and CIRCUITPY doesn't show up as a disk drive after installing CircuitPython, try loading this 'nuke' UF2 to RP2350. 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 loading this UF2, follow the steps above to re-install CircuitPython.

[Download flash erasing "nuke" UF2 for RP2350](https://cdn-learn.adafruit.com/assets/assets/000/132/526/original/rp2350_flash_nuke.uf2)
# Breakout Game on the Metro RP2350 and Fruit Jam

## Code for the Metro

## CircuitPython Usage

To use the game, you need to update&nbsp; **code.py** with the game program&nbsp;to the **CIRCUITPY** drive.

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.

Connect your board to your computer via a known good data+power USB cable. The board should show up in your File Explorer/Finder (depending on your operating system) as a flash drive named **CIRCUITPY**.

Extract the contents of the zip file, copy the **lib** directory files to **CIRCUITPY/lib**. Copy the **code.py** file to your **CIRCUITPY** drive. The program should self start.

![A screenshot of a list of files comprising this project listed by which directory they are contained in](https://adafruit.github.io/Adafruit_Learning_System_Guides/Metro_Metro_RP2350_Breakout.png )

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

## Code Principles

### USB Host Input

USB Host is relatively new to CircuitPython, first coming on Raspberry Pi RP2040-based boards.&nbsp;

Typically, one would access a USB port by:

- Establishing the USB connection
- Reading USB Reports, sections of bytes sent when an action occurs on the peripheral like a key is pressed or joystick moved.
- Parsing the reports and providing meaningful input to the program.

Python has the concept of standard input and output streams, similar to those in Linux/Unix and other operating systems. CircuitPython has this capability and through a lot of behind the scenes code, presents a USB keyboard as a stdin input device. The code to get USB Host Keyboard characters and echo them to serial out is as follows:

```python
import supervisor
import sys

while True:
    available = supervisor.runtime.serial_bytes_available
    if available:
        c = sys.stdin.read(available)
        print(c, end='')
```

While not every key on the keyboard has a single character representation, for simple gameplay this works very well! Using the gaming standard WASD keys for movement and the spacebar for Start is easily done and what is used in this project.

Type "q", "Q", or Esc to exit the game.

### Video Output

Video for this project is output via the Raspberry Pi HSTX peripheral. CircuitPython has the `picodvi` library which can set up the DVI graphics as a standard CircuitPython framebuffer usable by `displayio`. There are only certain display resolutions and color bit depths supported at present with lower resolutions "pixel doubled" to fit higher resolution HDMI displays. All that happens behind the scenes.

# Breakout Game on the Metro RP2350 and Fruit Jam

## CircuitPython on the Fruit Jam

[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 running on your board.

Warning: Please use the latest release of 10.x or higher for the Fruit Jam. Also use the latest libraries for the best functionality.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_fruit_jam/)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/655/medium640/install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg?1618943202)

![reset and boot highlighted](https://cdn-learn.adafruit.com/assets/assets/000/138/708/medium800/adafruit_products_Resetboot.jpg?1754331128 )

To enter the bootloader, hold down the **BOOT/**** BOOTSEL button**(highlighted in red above), and while continuing to hold it (don't let go!), press and release the**reset button**(highlighted in red or blue above).&nbsp;**Continue to hold the BOOT/BOOTSEL button until the RP2350 drive appears!**

If the drive does not appear, release all the buttons, and then repeat the process above.

You can also start with your board unplugged from USB, press and hold the BOOTSEL button (highlighted in red above), continue to hold it while plugging it into USB, and wait for the drive to appear before releasing the button.

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

You will see a new disk drive appear called **RP2350**.

&nbsp;

Drag the **adafruit-circuitpython-_boardname_-_language_-_version_.uf2** file to **RP2350.**

![install_circuitpython_on_rp2350_Screenshot_2024-09-11_111518.png](https://cdn-learn.adafruit.com/assets/assets/000/132/253/medium640/install_circuitpython_on_rp2350_Screenshot_2024-09-11_111518.png?1726067809)

![install_circuitpython_on_rp2350_Screenshot_2024-09-11_111742.png](https://cdn-learn.adafruit.com/assets/assets/000/132/254/medium640/install_circuitpython_on_rp2350_Screenshot_2024-09-11_111742.png?1726067866)

The **RP2350** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

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

![install_circuitpython_on_rp2350_Screenshot_2024-09-11_111843.png](https://cdn-learn.adafruit.com/assets/assets/000/132/255/medium640/install_circuitpython_on_rp2350_Screenshot_2024-09-11_111843.png?1726067932)

## Safe Mode

You want to edit your **code.py** or modify the files on your **CIRCUITPY** drive, but find that you can't. Perhaps your board has gotten into a state where **CIRCUITPY** is read-only. You may have turned off the **CIRCUITPY** drive altogether. Whatever the reason, safe mode can help.

Safe mode in CircuitPython does not run any user code on startup, and disables auto-reload. This means a few things. First, safe mode _bypasses any code in_ **boot.py** (where you can set **CIRCUITPY** read-only or turn it off completely). Second, _it does not run the code in_ **code.py**. And finally, _it does not automatically soft-reload when data is written to the_ **CIRCUITPY** _drive_.

Therefore, whatever you may have done to put your board in a non-interactive state, safe mode gives you the opportunity to correct it without losing all of the data on the **CIRCUITPY** drive.

### Entering Safe Mode
To enter safe mode when using CircuitPython, plug in your board or hit reset (highlighted in red above). Immediately after the board starts up or resets, it waits 1000ms. On some boards, the onboard status LED (highlighted in green above) will blink yellow during that time. If you press reset during that 1000ms, the board will start up in safe mode. It can be difficult to react to the yellow LED, so you may want to think of it simply as a slow double click of the reset button. (Remember, a fast double click of reset enters the bootloader.)

### In Safe Mode

If you successfully enter safe mode on CircuitPython, the LED will intermittently blink yellow three times.

If you connect to the serial console, you'll find the following message.

```terminal
Auto-reload is off.
Running in safe mode! Not running saved code.

CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.
```

You can now edit the contents of the **CIRCUITPY** drive. Remember, _your code will not run until you press the reset button, or unplug and plug in your board, to get out of safe mode._

## Flash Resetting UF2

If your board ever gets into a really _weird_ state and CIRCUITPY doesn't show up as a disk drive after installing CircuitPython, try loading this 'nuke' UF2 to RP2350. 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 loading this UF2, follow the steps above to re-install CircuitPython.

[Download flash erasing "nuke" UF2 for RP2350](https://cdn-learn.adafruit.com/assets/assets/000/132/526/original/rp2350_flash_nuke.uf2)
# Breakout Game on the Metro RP2350 and Fruit Jam

## Code the Fruit Jam

## CircuitPython Usage

To use the game, you need to update&nbsp; **code.py** with the game program&nbsp;to the **CIRCUITPY** drive.

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.

Connect your board to your computer via a known good data+power USB cable. The board should show up in your File Explorer/Finder (depending on your operating system) as a flash drive named **CIRCUITPY**.

Extract the contents of the zip file, copy the **lib** directory files to **CIRCUITPY/lib**. Copy the **code.py** file to your **CIRCUITPY** drive. The program should self start.

![](https://cdn-learn.adafruit.com/assets/assets/000/140/793/medium800/gaming_Fruit_Jam_FruitJam_Breakout.png?1761598085 It's a lot of library files but it's dependencies that does it)

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

## Code Principles

### USB Host Input

USB Host is relatively new to CircuitPython, first coming on Raspberry Pi RP2040-based boards.&nbsp;

Typically, one would access a USB port by:

- Establishing the USB connection
- Reading USB Reports, sections of bytes sent when an action occurs on the peripheral like a key is pressed or joystick moved.
- Parsing the reports and providing meaningful input to the program.

Python has the concept of standard input and output streams, similar to those in Linux/Unix and other operating systems. CircuitPython has this capability and through a lot of behind the scenes code, presents a USB keyboard as a stdin input device. The code to get USB Host Keyboard characters and echo them to serial out is as follows:

```python
import supervisor
import sys

while True:
    available = supervisor.runtime.serial_bytes_available
    if available:
        c = sys.stdin.read(available)
        print(c, end='')
```

While not every key on the keyboard has a single character representation, for simple gameplay this works very well! Using the gaming standard WASD keys for movement and the spacebar for Start is easily done and what is used in this project.&nbsp;

Press either "q", "Q", or the Esc key to quit.

## Sound Output

Currently sound is coded to the small speaker that comes with the Fruit Jam. A function duplicates the `tone()` function common on microcontrollers. But this one uses the Fruit Jam's built-in TLV320 I2C DAC.

### Video Output

Video for this project is output via the Raspberry Pi HSTX peripheral. The display handling is mostly done via the `adafruit_circuitPython_fruitjam` library. There are only certain display resolutions and color bit depths supported at present with lower resolutions "pixel doubled" to fit higher resolution HDMI displays. All that happens behind the scenes.

# Breakout Game on the Metro RP2350 and Fruit Jam

## Usage

Ensure a USB keyboard is plugged into the USB Host port wired up previously. Reset the board by cycling power or pressing the Reset button if you happen to plug in a keyboard after power up.

Be sure you connect the DVI breakout to an HDMI monitor and the monitor is on. You might need a long cable if your monitor is not near the Metro RP2350 (like a television). The cables are standard and may be obtained from any trusted retail outlet. Also reset the Metro if you plug in HDMI after powering the Metro.

Once connections are all set, power the Metro RP2350 either via USB C (5 volts) or the barrel connection (5.5 to 17 volts DC, center positive).

The game should auto start if all the software was loaded in the previous step. The colored blocks at the top, the paddle below.

## Gameplay
![A statis image of the game before play begins with colored blocks on the top quarter of the screeen and a single paddle at the bottom of the display. There is text stating hoow to begin and how many lives are left](https://cdn-learn.adafruit.com/assets/assets/000/135/643/medium800/gaming_20250303_192809a.jpg?1754939229 )

On-screen keys used in the game are displayed. The typical WASD directional keys are used (caps lock or not, no matter) and since the paddle only goes left and right, only A and D are used. The spacebar is used to start the game and when a turn is lost.

The "q", "Q", and Esc keys ends the program.

![A short animated gif showing the gameplay in action, using a keyboard to move the cursor to make contact with a moving ball such that the colored bricks are hit by the ball and removed](https://cdn-learn.adafruit.com/assets/assets/000/135/649/medium800thumb/gaming_Gameplay_%28short%29.jpg?1754939295 )

The goal is to keep hitting the bouncing ball, aiming to "break" (eliminate) all the colored blocks.

While the ball is falling, position the paddle so the ball will hit it and bounce up again.

If the ball hits the end of the paddle it may bounce in a shallow angle (glancing blow). If the paddle is moving when the ball hits it, the ball may not bounce at an equal and opposite angle but have "some english" from the paddle momentum.

Sound effects are played with each action on screen (if you have the piezo installed on Metro RP2350. It uses the built-in small speaker on Fruit Jam).

For each colored brick removed, you score 10 points. You win by eliminating all the bricks with the lives you have, scoring 500.

https://youtu.be/G53Kjd3u-pY

## Changing the Code

There are values in the code to adjust various parameters in the game if you want to simplify things or make things more challenging:

`lives` is the number of chances you have to get all the bricks cleared and is set by default at `3`.

`BALL_SPEED_INITIAL` is the speed the ball moves at the start. Increase or decrease for faster or slower play.

`PADDLE_WIDTH` is the width of the paddle in pixels. Making the paddle smaller makes things more challenging.

`PADDLE_SPEED` affects the speed at which the paddle can move when the A and D keys are pressed.

`BALL_RADIUS` changes the ball size.


## Featured Products

### Adafruit Fruit Jam - Mini RP2350 Computer

[Adafruit Fruit Jam - Mini RP2350 Computer](https://www.adafruit.com/product/6200)
We were catching up on a recent [hackaday hackchat with eben upton](https://hackaday.io/event/202122-raspberry-pi-hack-chat-with-eben-upton)&nbsp;and learned some fun facts: such as the DVI hack for the RP2040 was inspired by <a...></a...>

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

[Adafruit Metro RP2350](https://www.adafruit.com/product/6003)
Choo! Choo! This is the RP2350 Metro Line, making all station stops at "Dual Cortex M33 mountain", "528K RAM round-about" and "16 Megabytes of Flash town". This train is piled high with hardware that complements the Raspberry Pi RP2350 chip to make it an excellent...

In Stock
[Buy Now](https://www.adafruit.com/product/6003)
[Related Guides to the Product](https://learn.adafruit.com/products/6003/guides)
### USB Type A Jack Breakout Cable with Premium Female Jumpers

[USB Type A Jack Breakout Cable with Premium Female Jumpers](https://www.adafruit.com/product/4449)
If you'd like to connect a USB-host-capable chip to your USB peripheral, this cable will make the task very simple.&nbsp; **There is no converter chip in this cable!** &nbsp;It's basically a plain USB cable that's cut in half and with jumper sockets on the power and data...

In Stock
[Buy Now](https://www.adafruit.com/product/4449)
[Related Guides to the Product](https://learn.adafruit.com/products/4449/guides)
### Adafruit RP2350 22-pin FPC HSTX to DVI Adapter for HDMI Displays

[Adafruit RP2350 22-pin FPC HSTX to DVI Adapter for HDMI Displays](https://www.adafruit.com/product/6055)
You may have noticed that our [RP2350 Feather](https://www.adafruit.com/product/6000) has an FPC output connector on the end&nbsp;for accessing the HSTX (High Speed Transmission)&nbsp;peripheral. This new capability, not available on the RP2040, is specifically designed to allow the...

In Stock
[Buy Now](https://www.adafruit.com/product/6055)
[Related Guides to the Product](https://learn.adafruit.com/products/6055/guides)
### 22-pin 0.5mm pitch FPC Flex Cable for DSI CSI or HSTX - 20cm

[22-pin 0.5mm pitch FPC Flex Cable for DSI CSI or HSTX - 20cm](https://www.adafruit.com/product/6036)
Connect this to that when a 22-pin FPC connector is needed. This 20 cm long cable is made of a flexible PCB. It's A-B style, meaning that pin one on one side will match with pin one on the other. How handy!

[We're stocking this to...](https://www.adafruit.com/category/360)

In Stock
[Buy Now](https://www.adafruit.com/product/6036)
[Related Guides to the Product](https://learn.adafruit.com/products/6036/guides)
### Solderless Press-Fit Male Pin Header - 2.54mm / 0.1" Pitch

[Solderless Press-Fit Male Pin Header - 2.54mm / 0.1" Pitch](https://www.adafruit.com/product/5938)
If your soldering isn't quite up to scratch, or you yet don't own a soldering iron, then these nifty **0.1"/2.54mm&nbsp;standard pitch&nbsp;press-fit headers** might be just what you need.&nbsp;

**Absolutely no soldering required!** All that's...

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

[Piezo Buzzer](https://www.adafruit.com/product/160)
Piezo buzzers are used for making beeps, tones and alerts. This one is petite but loud! Drive it with 3-30V peak-to-peak square wave. To use, connect one pin to ground (either one) and the other pin to a square wave out from a timer or microcontroller. For the loudest tones, stay around 4 KHz,...

In Stock
[Buy Now](https://www.adafruit.com/product/160)
[Related Guides to the Product](https://learn.adafruit.com/products/160/guides)
### USB C to USB C Cable - USB 3.1 Gen 4 with E-Mark - 1 meter long

[USB C to USB C Cable - USB 3.1 Gen 4 with E-Mark - 1 meter long](https://www.adafruit.com/product/4199)
As technology changes and adapts, so does Adafruit! Rather than the regular USB A, this cable has&nbsp; **USB C to USB C** &nbsp;plugs!

USB C is the latest industry-standard connector for transmitting data&nbsp;_and_&nbsp;power. Like Lightning and MagSafe cables, USB C...

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

## Related Guides

- [Adafruit RP2350 22-pin FPC HSTX to DVI Adapter](https://learn.adafruit.com/adafruit-rp2350-22-pin-fpc-hstx-to-dvi-adapter.md)
- [Adafruit Metro RP2350](https://learn.adafruit.com/adafruit-metro-rp2350.md)
- [Adafruit Fruit Jam](https://learn.adafruit.com/adafruit-fruit-jam.md)
- [USB Game Controller with SNES-like Layout](https://learn.adafruit.com/usb-game-controller-with-snes-like-layout.md)
- [Return to The Matrix with the Metro RP2350 or Fruit Jam](https://learn.adafruit.com/return-to-the-matrix-with-the-metro-rp2350.md)
- [Using a Mouse with USB Host](https://learn.adafruit.com/using-a-mouse-with-usb-host.md)
- [Chip's Challenge on Fruit Jam and Metro RP2350](https://learn.adafruit.com/256-color-gaming-on-the-metro-rp2350.md)
- [Plotting Offline Data - JSONL to CSV files, filters and graphs](https://learn.adafruit.com/plotting-offline-data-jsonl-to-csv-files-filters-and-graphs.md)
- [Minesweeper on the Fruit Jam and Metro RP2350](https://learn.adafruit.com/minesweeper-on-metro-rp2350.md)
- [Solderless Robot Toy Xylophone](https://learn.adafruit.com/solderless-robot-toy-xylophone.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [Larsio Paint Music](https://learn.adafruit.com/larsio-paint-music.md)
- [Using a Keyboard with USB Host](https://learn.adafruit.com/using-a-keyboard-with-usb-host.md)
- [Flappy Nyan Cat Game on Fruit Jam and Metro RP2350](https://learn.adafruit.com/flappy-nyan-cat-game-on-metro-rp2350.md)
- [Feather RP2350 Audio Reactive Video Synth](https://learn.adafruit.com/feather-rp2350-audio-reactive-video-synth.md)
- [Tile-Matching Game on the Fruit Jam and Metro RP2350](https://learn.adafruit.com/tile-matching-game-on-the-adafruit-metro-rp2350.md)
- [Adafruit OLED Displays for Raspberry Pi](https://learn.adafruit.com/adafruit-oled-displays-for-raspberry-pi.md)
