# CLUE BLE MIDI Glove

## Overview

https://youtu.be/KNCbZwvCE1M

Send wireless MIDI continuous controller (CC) messages over the air to your favorite BLE synthesizer or synth app on iOS or mac os! This project uses the CLUE's built-in accelerometer and proximity sensor to send three different CC signals as you tilt and roll your hand.

Use the CLUE's TFT screen, buttons, and touch pads to select different CC numbers, and even pause/restart sending data while maintaining the BLE MIDI connection.

You can also change the sound of your synth entirely at the tap of a CLUE touchpad by sending Bank/Preset Program Change messages.

## Parts
Featured
### Adafruit CLUE - nRF52840 Express with Bluetooth® LE

[Adafruit CLUE - nRF52840 Express with Bluetooth® LE](https://www.adafruit.com/product/4500)
Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some projects that have a small screen and a lot of sensors. To make it compatible with existing projects, we made...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4500)
[Related Guides to the Product](https://learn.adafruit.com/products/4500/guides)
![Animated GIF showing CLUE board  displaying data from the many on-board sensors.](https://cdn-shop.adafruit.com/product-videos/640x480/4500-04.jpg)

Featured
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
![Front angled shot of 3 x AAA battery holder with on-off switch and 2-pin JST PH connector.](https://cdn-shop.adafruit.com/640x480/727-07.jpg)

Featured
### Alkaline AAA batteries - 3 pack

[Alkaline AAA batteries - 3 pack](https://www.adafruit.com/product/3520)
Battery power for your portable project! These batteries are good quality at a good price, and work fantastic with any of the kits or projects in the shop that use AAA's. This is a pack of **3 AAA batteries**.  
  
These batteries are Alkaline (MnO2) chemistry, with a...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3520)
[Related Guides to the Product](https://learn.adafruit.com/products/3520/guides)
![Angled shot of 3 PKcell AAA batteries. ](https://cdn-shop.adafruit.com/640x480/3520-00.jpg)

Featured
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

In Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
![USB cable - USB A to Micro-B - 3 foot long](https://cdn-shop.adafruit.com/640x480/592-01.jpg)

## Other Materials

In addition to the parts above you'll also need:

- Glove/mitten/fingerless glove or wrist strap
- Velcro or other material to adhere the CLUE to the glove/strap

# CLUE BLE MIDI Glove

## CircuitPython on CLUE

[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** &nbsp;flash drive to iterate.

The following instructions will show you how to install CircuitPython. If you've already installed CircuitPython but are looking to update it or reinstall it, the same steps work for that as well!

## Set up CircuitPython Quick Start!

Follow this quick step-by-step for super-fast Python power :)

[Download the latest version of CircuitPython for CLUE from circuitpython.org](https://circuitpython.org/board/clue_nrf52840_express/)
 **Click the link above to download the latest version of CircuitPython for the CLUE.**

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

![adafruit_products_CLUE_UF2_Downloaded.png](https://cdn-learn.adafruit.com/assets/assets/000/088/037/medium640/adafruit_products_CLUE_UF2_Downloaded.png?1580840077)

Plug your CLUE into your computer using a known-good USB cable.

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

Double-click the **Reset** button on the top (magenta arrow) on your board, and you will see the NeoPixel RGB LED (green arrow) turn green. If it turns red, check the USB cable, try another USB port, etc. **Note:** The little red LED next to the USB connector will pulse red. That's ok!

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

![adafruit_products_Clue_Reset_NeoPixel_bootloader.png](https://cdn-learn.adafruit.com/assets/assets/000/087/919/medium640/adafruit_products_Clue_Reset_NeoPixel_bootloader.png?1580496467)

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

Drag the **adafruit-circuitpython-clue-etc.uf2** file to **CLUE**** BOOT.**

![adafruit_products_CLUE_CLUEBOOT.png](https://cdn-learn.adafruit.com/assets/assets/000/088/042/medium640/adafruit_products_CLUE_CLUEBOOT.png?1580841287)

![adafruit_products_CLUE_drag_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/088/043/medium640/adafruit_products_CLUE_drag_UF2.png?1580841295)

The LED will flash. Then, the **CLUEBOOT** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

If this is the first time you're installing CircuitPython or you're doing a completely fresh install after erasing the filesystem, you will have two files - **boot\_out.txt** , and **code.py** , and one folder - **lib** on your **CIRCUITPY** drive.

If CircuitPython was already installed, the files present before reloading CircuitPython should still be present on your **CIRCUITPY** drive. Loading CircuitPython will not create new files if there was already a CircuitPython filesystem present.

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

![adafruit_products_CLUE_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/088/044/medium640/adafruit_products_CLUE_CIRCUITPY.png?1580841453)

# CLUE BLE MIDI Glove

## Make the CLUE MIDI Glove

## Text Editor

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

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

## Installing Project Code

To use with CircuitPython, you need to first install a few libraries, into the lib folder on your **CIRCUITPY** drive. Then you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **MIDI\_CLUE\_BLE\_Glove/** and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your **CIRCUITPY** drive.

Your **CIRCUITPY** drive should now look similar to the following image:

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

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

## How It Works

The code does a few key things at startup:

- Import necessary libraries, including the **adafruit\_ble\_midi** and **adafruit\_midi** libraries
- Creates variables to store:
  - output MIDI channel (can be set to 1-16)
  - three CC numbers (e.g. CC#1 = modulation)
  - list of MIDI Band/Preset pairs for changing patches

- Advertises the CLUE BLE MIDI peripheral over BLE so devices can connect to it
- Uses **displayio** to lay out the screen text and dividers
- Checks the two buttons and three touch pads to make any adjustments to variables and UI
- Waits for a BLE connection

## Sending Data

Once a connection has been established between the CLUE and a BLE MIDI device, here's what takes place:

- CLUE accelerometer readings on x- and y-axis are read and remapped using `simpleio.map_range()` command. Each axis reading ranges from **-9 to 9** and needs to re-map to MIDI **CC** ranges which is **0-127**. Depending on how you want to tilt your hand, you can pick and subset of the accelerometer's range per axis
- CLUE proximity sensor is remapped from **0-255** to **0-127**
- The remapped sensor data is sent as CC data over MIDI
- Similarly, when the CLUE's touch sensor #0 is pressed, a MIDI message is sent to toggle among the pre-selected **Bank/Patch** pairs. Note, the **Bank** choice is sent via **CC0** and/or **CC32** (Most Significant Bit and/or Least Significant Bit for Bank select varies by MIDI device manufacturer). The **Patch** choice is sent via **ProgramChange**

## CLUE UI

The CLUE's buttons and touch pads act as user inputs to adjust these things:

- **Touch #0** toggles between **Bank/Preset patches**
- **Touch #1** selects between the three **CC lines** on the screen (look for the small dot next to the selected line) to enable adjusting the CC numbers over which to send the sensor data
- **Buttons A** and **B** decrease and increase the MIDI **CC number** of the selected CC line
- **Touch #2** toggles **on/off** the sending of CC data (to give your arm a rest!)

## Build the Glove

Now that the CLUE is coded, you'll want to attach it to a glove back. You can use some double-stick foam tape or adhesive Velcro to attach it, or even a few stitches of strong thread.

You can also attach the battery pack the same way, or simply hold it in your hand during use.

## Use the MIDI Glove

To use the Power Glove MIDI controller with a mac os machine, [follow these setup instructions](https://support.apple.com/guide/audio-midi-setup/set-up-bluetooth-midi-devices-ams33f013765/mac).

On iOS devices, you can use the [MIDI Wrench app](https://crudebyte.com/mobile/midi_wrench/) to create and test the BLE MIDI connection, and then use it to "port" the MIDI messages to other apps, such as [AudioKit Synth One](https://audiokitpro.com/synth/) and [Moog Minimoog](https://www.moogmusic.com/products/minimoog-model-d-synthesizer-app) which you can see in action below:

https://youtu.be/KNCbZwvCE1M

Most of these software synths will provide a way to map CC values to any function you like, often with a "MIDI learn" mode as well as explicit number entry.

You can also use BLE MIDI with some hardware synthesizers, as well as with BLE MIDI add-on dongles, such as [this one from Yamaha](https://usa.yamaha.com/products/music_production/accessories/md-bt01/index.html) which adds BLE MIDI to synths with classic DIN-5 MIDI.


## Guide Products

### Adafruit CLUE - nRF52840 Express with Bluetooth® LE

[Adafruit CLUE - nRF52840 Express with Bluetooth® LE](https://www.adafruit.com/product/4500)
Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some projects that have a small screen and a lot of sensors. To make it compatible with existing projects, we made...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4500)
[Related Guides to the Product](https://learn.adafruit.com/products/4500/guides)
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
### Alkaline AAA batteries - 3 pack

[Alkaline AAA batteries - 3 pack](https://www.adafruit.com/product/3520)
Battery power for your portable project! These batteries are good quality at a good price, and work fantastic with any of the kits or projects in the shop that use AAA's. This is a pack of **3 AAA batteries**.  
  
These batteries are Alkaline (MnO2) chemistry, with a...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3520)
[Related Guides to the Product](https://learn.adafruit.com/products/3520/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

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

## Related Guides

- [Introducing Adafruit CLUE](https://learn.adafruit.com/adafruit-clue.md)
- [Archimedes' Boat](https://learn.adafruit.com/archimedes-boat.md)
- [eInk / ePaper Weather Station](https://learn.adafruit.com/epaper-weather-station.md)
- [Flashing LED Strand with MakeCode](https://learn.adafruit.com/flashing-led-strand-with-makecode.md)
- [Making a Name Tag in MakeCode Arcade](https://learn.adafruit.com/making-a-name-tag-in-makecode-arcade.md)
- [Makey Paper Craft ](https://learn.adafruit.com/makey-paper-craft.md)
- [CLUE Step Counter](https://learn.adafruit.com/clue-step-counter-st-lsm6ds33.md)
- [CLUE Altimeter](https://learn.adafruit.com/clue-altimeter.md)
- [Glowing Slime Lunchbox](https://learn.adafruit.com/glowing-slime-lunchbox.md)
- [Crickit Dancing Marionette Kit](https://learn.adafruit.com/universal-marionette-with-crickit.md)
- [Raspberry Pi SelfieBlock](https://learn.adafruit.com/selfieblock.md)
- [No-Touch Hand Wash Timer for Circuit Playground Express and CLUE](https://learn.adafruit.com/no-touch-hand-wash-timer-for-cpx-and-clue.md)
- [NeoTrellis Tabletop RPG Soundboard](https://learn.adafruit.com/neotrellis-dungeon-crawl-soundboard.md)
- [The MonkMakes Plant Monitor and CircuitPython](https://learn.adafruit.com/monkmakes-plant-monitor-and-circuitpython.md)
- [Tiny Museum Tour Device](https://learn.adafruit.com/tiny-museum-tour-device.md)
- [Light-Up Costumes in Harsh Environments](https://learn.adafruit.com/light-up-costumes-in-harsh-environments.md)
