# Glider Paper Airplane Controller

## Overview

https://youtu.be/X5RGamY7cbk

![](https://cdn-learn.adafruit.com/assets/assets/000/110/935/medium800/projects_edited_P1320902.png?1650395117)

[Glider is a classic Macintosh game](https://en.wikipedia.org/wiki/Glider_(video_game)) where you guide a paper airplane through a series of rooms. What could make this game even better? Controlling it with an actual paper airplane! You'll combine your paper airplane with an nRF52840 LED Glasses Driver board running CircuitPython to guide your glider to glory.&nbsp;

The nRF52840 LED Glasses Driver has Bluetooth and an onboard accelerometer. The LIS3DH accelerometer detects the angle of the paper airplane. The CircuitPython code converts the angle to a keypress to control the game over BLE.

![projects_edited_P1320900.png](https://cdn-learn.adafruit.com/assets/assets/000/110/933/medium640/projects_edited_P1320900.png?1650395016)

There is a 3D printed part for your paper airplane to slot into. The board has a case that attaches to the paper airplane holder.

![projects_edited_P1320897.png](https://cdn-learn.adafruit.com/assets/assets/000/110/934/medium640/projects_edited_P1320897.png?1650395091)

## Prerequisite Guides
[Adafruit EyeLights LED Glasses and Driver](https://learn.adafruit.com/adafruit-eyelights-led-glasses-and-driver)
[Adafruit LIS3DH Triple-Axis Accelerometer Breakout](https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout)
## Parts
### Adafruit LED Glasses Driver - nRF52840 Sensor Board

[Adafruit LED Glasses Driver - nRF52840 Sensor Board](https://www.adafruit.com/product/5217)
This board is designed to be a thin, Bluetooth®-enabled driver board for our [Adafruit LED Glasses](https://www.adafruit.com/product/5210) RGB LED matrix. That said, it's a perfectly good stand-alone development board for the Nordic nRF52840 chipset, with a very slim design,...

In Stock
[Buy Now](https://www.adafruit.com/product/5217)
[Related Guides to the Product](https://learn.adafruit.com/products/5217/guides)
![Angled shot of thin, rectangular Bluetooth LED driver board.](https://cdn-shop.adafruit.com/640x480/5217-07.jpg)

### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
![Angled shot of a Lithium Ion Polymer Battery 3.7V 500mAh with JST-PH connector.](https://cdn-shop.adafruit.com/640x480/1578-03.jpg)

### Pink and Purple Woven USB A to USB C Cable - 1 meter long

[Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153)
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;&nbsp;[If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5153)
[Related Guides to the Product](https://learn.adafruit.com/products/5153/guides)
![Angled shot of coiled pink and purple USB cable with USB A and USB C connectors.](https://cdn-shop.adafruit.com/640x480/5153-02.jpg)

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

Out of Stock
[Buy Now](https://www.adafruit.com/product/4199)
[Related Guides to the Product](https://learn.adafruit.com/products/4199/guides)
![USB C to USB C cable. USB 3.1 gen 4 with E-Mark. 1 meter long](https://cdn-shop.adafruit.com/640x480/4199-01.jpg)

### Part: 320PCS M2 Male Female Nylon Hex Spacer Standoff Screw Nut Kit
quantity: 1
M2 hardware
[320PCS M2 Male Female Nylon Hex Spacer Standoff Screw Nut Kit](https://www.amazon.com/dp/B07D78PFQL?psc=1&ref=ppx_yo2ov_dt_b_product_details)

# Glider Paper Airplane Controller

## 3D Printing

![](https://cdn-learn.adafruit.com/assets/assets/000/110/885/medium800/projects_edited_P1320867.png?1650302133)

The controller may be housed in a 3D printed case, described below. The case consists of three parts: a top lid, a board case and a paper airplane holder. All parts print with no supports.

The STL files can be downloaded directly here or from Thingiverse.

[paperAirplaneControllerSTL.zip](https://cdn-learn.adafruit.com/assets/assets/000/110/889/original/paperAirplaneControllerSTL.zip?1650302338)
[Thingiverse download](https://www.thingiverse.com/thing:5358146)
The nRF52840 LED Glasses Driver mounts to the board case using M2 screws and stand-offs.

![projects_edited_P1320874.png](https://cdn-learn.adafruit.com/assets/assets/000/110/886/medium640/projects_edited_P1320874.png?1650302183)

The paper airplane holder has a slot for your paper airplane to sit in.&nbsp;

![projects_edited_P1320872.png](https://cdn-learn.adafruit.com/assets/assets/000/110/888/medium640/projects_edited_P1320872.png?1650302276)

The paper airplane holder has mounting holes to attach to the board case.

![projects_edited_P1320880.png](https://cdn-learn.adafruit.com/assets/assets/000/110/887/medium640/projects_edited_P1320880.png?1650302226)

# Glider Paper Airplane Controller

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

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

Save it wherever is convenient for you.

![install_circuitpython_on_most_boards_CircuitPython_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/102/129/medium640/install_circuitpython_on_most_boards_CircuitPython_downloaded.jpg?1620922559)

![](https://cdn-learn.adafruit.com/assets/assets/000/105/173/medium800/adafruit_products_EyeLightsD_Reset_NeoPixel.jpg?1633470769)

Plug your board into your computer, using a known-good data-sync cable, directly, or via an adapter if needed.

Double-click the **reset** button (highlighted in red above), and you will see the **RGB status LED(s)** turn green (highlighted in green above). If you see red, try another port, or if you're using an adapter or hub, try without the hub, or different adapter or hub.

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

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 **GLASSESBOOT**.

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **GLASSESBOOT**.

![adafruit_products_EyeLights_UF2_downloaded_GLASSESBOOT.png](https://cdn-learn.adafruit.com/assets/assets/000/105/174/medium640/adafruit_products_EyeLights_UF2_downloaded_GLASSESBOOT.png?1633471162)

![adafruit_products_EyeLights_drag_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/105/175/medium640/adafruit_products_EyeLights_drag_UF2.png?1633471170)

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

That's it!

![install_circuitpython_on_most_boards_CIRCUITPY.jpg](https://cdn-learn.adafruit.com/assets/assets/000/102/130/medium640/install_circuitpython_on_most_boards_CIRCUITPY.jpg?1620923145)

# Glider Paper Airplane Controller

## Coding the Glider Paper Airplane Controller

Once you've finished setting up your nRF52840 LED Glasses Driver with CircuitPython, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **&nbsp;Download Project Bundle** &nbsp;button in the window below. It will download as a zipped folder.

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

## Upload the Code and Libraries to the nRF52840 LED Glasses Driver

After downloading the Project Bundle, plug your nRF52840 LED Glasses Driver into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called&nbsp; **CIRCUITPY**. Unzip the folder and copy the following items to the nRF52840 LED Glasses Driver's&nbsp; **CIRCUITPY** &nbsp;drive.&nbsp;

- **lib** &nbsp;folder
- **code.py**

Your nRF52840 LED Glasses Driver&nbsp; **CIRCUITPY&nbsp;** drive should look like this after copying the&nbsp; **lib** &nbsp;folder and the&nbsp; **code.py&nbsp;** file.

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/Glider_Paper_Airplane_Controller.png )

## Other Board Options

You could also use the [Feather nRF52840 Sense](https://learn.adafruit.com/adafruit-feather-sense) board, since it also has BLE and an onboard accelerometer. The Feather nRF52840 Sense's accelerometer is a LSM6DS33, different from the nRF52840 LED Glasses Driver's LIS3DH. As a result, you would need to change the code to use the LSM6DS33 library.

Additionally, the [LIS3DH accelerometer](https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout) is available as a STEMMA board. You could use that breakout with any CircuitPython compatible board with the code included on this page.

## How the CircuitPython Code Works
Before the loop, the LIS3DH accelerometer, HID keyboard and BLE are setup.

```python
#  I2C setup
i2c = board.I2C()
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c)

#  range of LIS3DH
lis3dh.range = adafruit_lis3dh.RANGE_2_G

#  BLE HID setup
hid = HIDService()

advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "CircuitPython HID"

#  BLE instance
ble = adafruit_ble.BLERadio()

#  keyboard HID setup
keyboard = Keyboard(hid.devices)

#  BLE advertisement
if not ble.connected:
    print("advertising")
    ble.start_advertising(advertisement, scan_response)
else:
    print("connected")
    print(ble.connections)
```

### Reading and Mapping Y
The accelerometer's value is read in the loop. For the purposes of controlling Glider, you only need to look at the `y` axis. The `y` axis will tell you whether you are tilting the board up or down.

The range of `y` is mapped to a range of `0` to `3` and then converted to an integer. As a result, when you're tilting the board down `plane` will be `0`. When you're not tilting the board at all, `plane` will be `1`. When you're tilting the board up, `plane` will be `2`.

```python
x, y, z = [
            value / adafruit_lis3dh.STANDARD_GRAVITY for value in lis3dh.acceleration
        ]
        #  map Y coordinate of LIS3DH
        mapped_y = simpleio.map_range(y, -1.1, 1.1, 0, 3)
        #  convert mapped value to an integer
        plane = int(mapped_y)
```

### Sending Key Presses
With the `y` axis mapped, you have three states for the tilt of your board: up, none and down. Each of these states has an assigned keyboard command. When you are tilting the board down, `Keycode.R` is sent. This moves the glider right in the game. When you are tilting the board up, `Keycode.L` is sent. This moves the glider left in the game. When you aren't tilting the board at all, all keys are released with the `keyboard.release_all()` function.

If you wanted to change the keycodes, you would edit this portion of the code.

```python
#  if you're tilting down...
        if plane == 0:
            #  send R, glider moves right
            keyboard.press(Keycode.R)
            #  debug
            #  print("right")
        #  if there's no tilt...
        if plane == 1:
            #  release all keys, send nothing to glider
            keyboard.release_all()
            #  debug
            #  print("none")
        #  if you're tilting up...
        if plane == 2:
            #  send L, glider moves left
            keyboard.press(Keycode.L)
            #  debug
            #  print("left")
```

# Glider Paper Airplane Controller

## Fold Your Airplane

There are many ways to fold a [paper airplane](https://en.wikipedia.org/wiki/Paper_plane). In the Wikipedia article on paper airplanes, there is a [classic design](https://en.wikipedia.org/wiki/File:Paper_Airplane.png) that you can fold that is detailed in the following section.

Fold your piece of paper in half length-wise.&nbsp;

![projects_edited_P1320855.png](https://cdn-learn.adafruit.com/assets/assets/000/110/814/medium640/projects_edited_P1320855.png?1649960795)

Unfold your piece of paper.

![projects_edited_P1320857.png](https://cdn-learn.adafruit.com/assets/assets/000/110/815/medium640/projects_edited_P1320857.png?1649960827)

Fold the top two corners towards the center fold.

![projects_edited_P1320858.png](https://cdn-learn.adafruit.com/assets/assets/000/110/816/medium640/projects_edited_P1320858.png?1649960861)

To make the wings, fold the corners in half towards the center. Your plane should have a sharp point.

![projects_edited_P1320860.png](https://cdn-learn.adafruit.com/assets/assets/000/110/817/medium640/projects_edited_P1320860.png?1649960944)

Flip the paper over. Fold the plane in half again using the original center fold.

![projects_edited_P1320862.png](https://cdn-learn.adafruit.com/assets/assets/000/110/818/medium640/projects_edited_P1320862.png?1649960991)

Fold each wing in half. Bring the edge of the wing down to the center fold of the plane.

![projects_edited_P1320863.png](https://cdn-learn.adafruit.com/assets/assets/000/110/819/medium640/projects_edited_P1320863.png?1649961072)

Now you have a paper airplane!

![](https://cdn-learn.adafruit.com/assets/assets/000/110/820/medium800/projects_P1320865.jpg?1649961150)

# Glider Paper Airplane Controller

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/110/928/medium800/projects_edited_P1320882.png?1650392030)

## Solder the Lipo Charge Jumper
The nRF52840 LED Glasses Driver does not support LiPo batteries by default. To use it with a LiPo battery in this project, you will need to solder the jumper on the back of the board to short it.

![projects_IMG_4781.jpg](https://cdn-learn.adafruit.com/assets/assets/000/110/812/medium640/projects_IMG_4781.jpg?1649958521)

![projects_IMG_4783.jpg](https://cdn-learn.adafruit.com/assets/assets/000/110/813/medium640/projects_IMG_4783.jpg?1649958532)

Warning: 

## Mount the Board
In the board's four mounting holes, attach M2 screws and stand-offs.

![projects_edited_P1320886.png](https://cdn-learn.adafruit.com/assets/assets/000/110/890/medium640/projects_edited_P1320886.png?1650307607)

Plug in a LiPo battery to the board.&nbsp;

![projects_edited_P1320887.png](https://cdn-learn.adafruit.com/assets/assets/000/110/896/medium640/projects_edited_P1320887.png?1650308149)

Slot the board's stand-offs into the case's mounting holes.

![projects_edited_P1320888.png](https://cdn-learn.adafruit.com/assets/assets/000/110/891/medium640/projects_edited_P1320888.png?1650307654)

![projects_edited_P1320889.png](https://cdn-learn.adafruit.com/assets/assets/000/110/892/medium640/projects_edited_P1320889.png?1650307686)

Secure the board's bottom two stand-offs with M2 nuts.

![projects_edited_P1320892.png](https://cdn-learn.adafruit.com/assets/assets/000/110/893/medium640/projects_edited_P1320892.png?1650307750)

Attach the case to the airplane holder with two M2 nuts.

![projects_edited_P1320894.png](https://cdn-learn.adafruit.com/assets/assets/000/110/894/medium640/projects_edited_P1320894.png?1650308119)

Close the case with the case lid.

![projects_edited_P1320895.png](https://cdn-learn.adafruit.com/assets/assets/000/110/895/medium640/projects_edited_P1320895.png?1650307949)

Insert your paper airplane into the airplane holder. Now you're ready to fly!

![](https://cdn-learn.adafruit.com/assets/assets/000/110/897/medium800/projects_edited_P1320896.png?1650308029)

# Glider Paper Airplane Controller

## Usage

## Game Software
The original Glider game is available on the [Internet Archive](https://archive.org/details/GliderMacintosh).

![projects_gameAction.png](https://cdn-learn.adafruit.com/assets/assets/000/110/810/medium640/projects_gameAction.png?1649947950)

Before beginning a game, check the Game Controls by clicking on Options and Controls...

![projects_gameControls.png](https://cdn-learn.adafruit.com/assets/assets/000/110/806/medium640/projects_gameControls.png?1649947725)

Make sure that **l** is set for left and **r** is set for right. This matches the CircuitPython code.

![projects_gameControlsSelect.png](https://cdn-learn.adafruit.com/assets/assets/000/110/808/medium640/projects_gameControlsSelect.png?1649947855)

Begin a new game by clicking on Game and Begin Game.

![projects_beginGame.png](https://cdn-learn.adafruit.com/assets/assets/000/110/809/medium640/projects_beginGame.png?1649947892)

## Game Play
Tilt your paper airplane down to move right.

![projects_downDemo.gif](https://cdn-learn.adafruit.com/assets/assets/000/110/937/medium640thumb/projects_downDemo.jpg?1650397500)

Tilt your paper airplane up to move left.

![projects_upDemo.gif](https://cdn-learn.adafruit.com/assets/assets/000/110/936/medium640thumb/projects_upDemo.jpg?1650397217)


## Featured Products

### Adafruit LED Glasses Driver - nRF52840 Sensor Board

[Adafruit LED Glasses Driver - nRF52840 Sensor Board](https://www.adafruit.com/product/5217)
This board is designed to be a thin, Bluetooth®-enabled driver board for our [Adafruit LED Glasses](https://www.adafruit.com/product/5210) RGB LED matrix. That said, it's a perfectly good stand-alone development board for the Nordic nRF52840 chipset, with a very slim design,...

In Stock
[Buy Now](https://www.adafruit.com/product/5217)
[Related Guides to the Product](https://learn.adafruit.com/products/5217/guides)
### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
### Pink and Purple Woven USB A to USB C Cable - 1 meter long

[Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153)
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;&nbsp;[If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5153)
[Related Guides to the Product](https://learn.adafruit.com/products/5153/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...

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

## Related Guides

- [Adafruit EyeLights LED Glasses and Driver](https://learn.adafruit.com/adafruit-eyelights-led-glasses-and-driver.md)
- [Wirelessly Code your Bluetooth Device with CircuitPython](https://learn.adafruit.com/wirelessly-code-your-bluetooth-device-with-circuitpython.md)
- [3D Printed Frame for Adafruit IS31FL3741 LED Glasses](https://learn.adafruit.com/3d-printed-frame-for-led-glasses-is31fl3741.md)
- [Exercise Buddy: Motion aware BLE media controller](https://learn.adafruit.com/exercise-buddy.md)
- [LED Glasses Custom Animated Graphics with Sprites](https://learn.adafruit.com/led-glasses-custom-animated-graphics-with-sprites.md)
- [PyPortal Voice Controlled Smart Switch and Time Display](https://learn.adafruit.com/pyportal-voice-controlled-smart-switch-and-time-display.md)
- [Adafruit Infrared IR Remote Transceiver](https://learn.adafruit.com/adafruit-infrared-ir-remote-transceiver.md)
- [Minesweeper on the Fruit Jam and Metro RP2350](https://learn.adafruit.com/minesweeper-on-metro-rp2350.md)
- [Adafruit PCF8575 I2C 16 GPIO Expander Breakout](https://learn.adafruit.com/adafruit-pcf8575.md)
- [Princess Peach LED Crown](https://learn.adafruit.com/bowsette.md)
- [Fruit Jam Sega Genesis](https://learn.adafruit.com/fruit-jam-sega-genesis.md)
- [Adafruit Wiz5500 Ethernet Co-Processor Breakout Board](https://learn.adafruit.com/adafruit-wiz5500-ethernet-co-processor-breakout-board.md)
- [Theme Park Wait Time Display](https://learn.adafruit.com/park-wait-time.md)
- [CircuitPython Safe Mode](https://learn.adafruit.com/circuitpython-safe-mode.md)
- [Reverse Engineering a Bluetooth Low Energy Light Bulb](https://learn.adafruit.com/reverse-engineering-a-bluetooth-low-energy-light-bulb.md)
