# Circuit Playground Express USB MIDI Controller and Synthesizer

## Overview

https://youtu.be/O-VdYYtkbyM

This project turns the Circuit Playground Express (CPX) board into a touch pad USB [MIDI controller](https://en.wikipedia.org/wiki/MIDI_controller "Wikipedia: MIDI controller") with tilt control for modulation and pitch bend similar to the excellent [Trellis M4 Expressive MIDI controller](https://learn.adafruit.com/trellis-m4-midi-keypad-and-tilt-controller "Adafruit Learn: Trellis M4 Expressive MIDI controller") project.

A second partner program creates a basic [MIDI](https://www.midi.org/ "The MIDI Association")-enabled synthesizer using the onboard speaker.

The USB MIDI features require CircuitPython 4.x or higher and a recent version of the `adafruit_midi` library.

No additional hardware is required beyond the Circuit Playground Express board. Multiple boards can be used to increase the note range on the controller or for simple&nbsp; [polyphony](https://en.wikipedia.org/wiki/Polyphony "Wikipedia: polyphony") on the synthesizer.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/975/medium800/circuitpython_cpx-over-synth-ports-tightcrop-2452.jpg?1556235554)

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### USB A/Micro Cable - 2m

[USB A/Micro Cable - 2m](https://www.adafruit.com/product/2185)
This is your standard USB A-Plug&nbsp;to Micro-USB cable. It's 2 meters long so you'll have plenty of cord to work with for those longer extensions.

In Stock
[Buy Now](https://www.adafruit.com/product/2185)
[Related Guides to the Product](https://learn.adafruit.com/products/2185/guides)
![USB Cable with Type A and Micro B ends](https://cdn-shop.adafruit.com/640x480/2185-00.jpg)

# Circuit Playground Express USB MIDI Controller and Synthesizer

## Controllers and Instruments

![](https://cdn-learn.adafruit.com/assets/assets/000/074/628/medium800/circuitpython_siemens-synthesizer-deutsches-museum-2000.jpg?1555698441 Siemens Synthesizer in Deutsches Museum, Munich. Photograph by Kevin Walters.)

## MIDI History

Early electronic instruments like the [RCA Synthesizer Mark II](https://120years.net/the-rca-synthesiser-i-iiharry-olsen-hebert-belarusa1952/ "120 Years of Electronic Music: RCA Synthesizer MkII") or [Siemens Synthesizer](https://120years.net/the-siemens-synthesiserh-klein-w-schaafgermany1959/ "120 Years of Electronic Music: Siemens Synthesizer") (above) from 1950s were built by one manufacturer with proprietary interconnections. The advent of [modular synthesizers](https://en.wikipedia.org/wiki/Modular_synthesizer "Wikipedia: modular synthesizers") led to a simple interface with _analogue_ signals in the form of a [control voltage and gate](https://en.wikipedia.org/wiki/CV/gate "Wikipedia: CV/gate") signal pair which could connect keyboards (a controller) and sequencers to other electronic instruments.

In the early 1980s, manufacturers collaborated on the first MIDI standard which was published in 1983. From [www.midi.org](https://www.midi.org/ "MIDI Manufacturer's Association"):

> MIDI is an industry standard music technology protocol that connects products from many different companies including digital musical instruments, computers, tablets, and smartphones. MIDI is used every day around the world by musicians, DJs, producers, educators, artists, and hobbyists to create, perform, learn, and share music and artistic works.
> 
> MIDI Manufacturer's Association

[Colin's Lab: MIDI](https://learn.adafruit.com/collins-lab-midi "Adafruit: Colin's Lab: MIDI") is a great video introduction to MIDI. There is also a transcript of the video.

## Expressive Controllers

Some instruments allow more variation (modulation) of the note than others. For example, the main variation a pianist can achieve is through the velocity of the key strike which determines how the hammer hits the strings. Other instruments like the violin have more possibilities for continuous modulation, i.e. variation of the note while it's being played.

For electronic instruments, the key-less [theremin](https://en.wikipedia.org/wiki/Theremin "Wikipedia: theremin") is perhaps the most well-known, expressive one. A less well-known early electronic instrument is the remarkable [ondes Martenot](https://en.wikipedia.org/wiki/Ondes_Martenot "Wikipedia: ondes Martenot") which had a continuous pitch ring, lateral movement for pitch on later keybeds and a pressure sensitive button ("lozenge") for varying volume (amplitude modulation). The pre-MIDI [Yamaha CS-80](https://en.wikipedia.org/wiki/Yamaha_CS-80 "Wikipedia: Yamaha CS-80") was first synthesizer with polyphonic [aftertouch](https://www.sweetwater.com/insync/aftertouch/ "Sweetwater Sound: Glossary: aftertouch"), modulation achieved by placing additional pressure on the depressed key(s) after the initial strike.

[ROLI](https://roli.com/ "ROLI") make the most common, modern, highly&nbsp;[expressive keyboards](https://en.wikipedia.org/wiki/Keyboard_expression "Wikipedia: keyboard expression")&nbsp;using the relatively new&nbsp;[MIDI Polyphonic Expression (MPE)](https://en.wikipedia.org/wiki/MIDI#MIDI_Polyphonic_Expression "Wikipedia: MIDI Polyphonic Expression") standard. Another example is the [MI.MU Glove](https://mimugloves.com/ "MI.MU Glove") controller and its simpler cousin the (non-MIDI) [MINI.MU Glove](https://www.adafruit.com/product/4141 "MINI.MU Glove").

## CPX and MIDI

The `adafruit_midi` CircuitPython library includes support for sending and receiving MIDI messages (sometimes called [events](https://www.midi.org/specifications-old/item/table-1-summary-of-midi-message "MIDI Manufacturer's Association: Summary of MIDI Messages (1.0)")) over USB. This library is used by the two programs in this guide.

### MIDI controller

The first program creates a MIDI controller using the 7 capacitive touch pads on the CPX as keys and the onboard accelerometer to apply expressive effects by measuring tilt to control the pitch bend and modulation wheels. The two CPX buttons are used to change octave/semitone offset and the keyboard scale. The switch inhibits the tilt control and selects between octave and semitone change.

### Basic Synthesizer

The second program creates a MIDI-enabled synth on the CPX which plays a sawtooth wave of the appropriate pitch and volume for the incoming notes. Pitch bending and a limited form of amplitude modulation are implemented.

Both programs uses the NeoPixels to represent the note pressed/played.

# Circuit Playground Express USB MIDI Controller and Synthesizer

## CircuitPython

Info: 

If you are new to CircuitPython, see [Welcome to CircuitPython!](https://learn.adafruit.com/welcome-to-circuitpython "Adafruit: Welcome to CircuitPython!")

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython.&nbsp;[You can learn about Mu and its installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

## Libraries

Download the latest set of libraries for CircuitPython to match the version of CircuitPython you are running. There is one library package for CircuitPython 3.x, 4.x, and so on. Click the box below and download the library bundle to your computer.

[Click to go to the latest Adafruit CircuitPython Library Bundle Release Page](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest)
Open the library Zip file and copy the following files/directories onto the CPX **CIRCUITPY** &nbsp;drive in a directory called **/lib**. This library is the one used by the programs:

- `adafruit_midi` (_must_ be adafruit-circuitpython-bundle-4.x-mpy-20190507.zip or later)

See the [CircuitPython Libraries](https://learn.adafruit.com/adafruit-hallowing/circuitpython-libraries "Adafruit: Hallowing: CircuitPython Libraries") guide for additional details on how to add libraries.

This code has been tested on CircuitPython 4.0.0 rc1 and the adafruit-circuitpython-bundle-4.x-mpy-20190507 libraries.

# Circuit Playground Express USB MIDI Controller and Synthesizer

## Waveforms

![](https://cdn-learn.adafruit.com/assets/assets/000/075/115/medium800/circuitpython_cat-oscilloscope-43cropsquash-2000.jpeg?1556705019 Cat admiring an unrelated waveform. Photograph by Yann (@mwyann).)

The CPX basic synthesizer uses a small sample made from a list of 12 values to create a low resolution sawtooth wave. This sample is played repeatedly as a loop at a playback rate adjusted to match the desired note frequency. For example, the note **A<sub>4</sub>** (440Hz) would be played at 12 \* 440 = 5280 samples per second.

The CPX has an upper playback limit of 350000 samples per second which dictates an upper frequency for this sample of 29167Hz, well into the inaudible, [ultrasonic](https://en.wikipedia.org/wiki/Ultrasound "Wikipedia: ultrasound") range. This technique to change the audible frequency of a sample clearly has limitations with large samples.

Two cycles of the low resolution, "[steppy](https://en.wikipedia.org/wiki/Zero-order_hold "Wikipedia: zero-order hold")" sawtooth wave are shown below alongside the maximum resolution equivalent. CircuitPython uses values 0-65535 (16bit) to represent the output value/voltage. The CPX's SAMD21 processor's [digital to analogue converter (DAC)](https://en.wikipedia.org/wiki/Digital-to-analog_converter "Wikipedia: digital to analogue converter (DAC)") is only 10bit, reducing ([quantizing](https://en.wikipedia.org/wiki/Quantization_(signal_processing) "Wikipedia: quantization")) the resolution to 1024 values.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/684/medium800/circuitpython_cpx-basic-synth-sawtooth-waves-1.png?1555804189)

The two different resolution sawtooth waves can be seen decomposed into multiple [sine waves](https://en.wikipedia.org/wiki/Sine_wave "Wikipedia: sine wave") of different frequencies on the audio spectra below. This is what would be seen on a [spectrum analyzer](https://en.wikipedia.org/wiki/Spectrum_analyzer "Wikipedia: spectrum analyzer") analysing either the the signal from the DAC output (touchpad **A0** ) or that signal played through a _high fidelity_ sound system. In this case, the bar graph was generated mathematically from the magnitude of the [Discrete Fourier Transform (DFT)](https://en.wikipedia.org/wiki/Discrete_Fourier_transform "Wikipedia: Discrete Fourier transform").

![](https://cdn-learn.adafruit.com/assets/assets/000/074/685/medium800/circuitpython_cpx-basic-synth-sawtooth-spectra-1.png?1555804200)

The expected highest (loudest) frequency is the fundamental occurring at 440Hz and then extra harmonics at 880Hz (2x) and 1320Hz (3x) and so on. The steppy quality of the low resolution sawtooth removes the 5280Hz, 10560Hz and 15840Hz harmonics, visible as absent red bars in the graph.

The graph stops at 20kHz, an oft-used upper limit for [human hearing](https://en.wikipedia.org/wiki/Hearing#Frequency_range "Wikipedia: hearing"). The curve suggests the harmonics _continue_ into the ultrasound range. This can be problematic if the audio signal is going to be used (sampled) by another digital device without [filtering](https://en.wikipedia.org/wiki/Anti-aliasing_filter "Wikipedia: anti-aliasing filter") to remove the higher frequencies.

The actual sound from the CPX is further affected by the characteristics of the onboard [(Class D) amplifier](https://en.wikipedia.org/wiki/Class-D_amplifier "Wikipedia: class-D amplifier") and the tiny 7.5mm speaker.

An explanation for why humans perceive sound mostly in terms of the frequencies of the constituent sine waves can be found in [Chapter 1 of David Benson's Book, Music: A Mathematical Offering](https://web.archive.org/web/20160616042935/http://homepages.abdn.ac.uk/mth192/pages/html/music.pdf "David Benson: Music: A Mathematical Offering (pdf version)").

## Simple Computer Sound Generation

It is trivial for a digital computer to generate square waves where the signal simply rises and falls with the pauses between determining the frequency and [duty cycle](https://en.wikipedia.org/wiki/Duty_cycle "Wikipedia: duty cycle"). These are commonly used for computer [clock signals](https://en.wikipedia.org/wiki/Clock_signal "Wikipedia: clock signal") but can also be used for generating audio. This would seem like an obvious, straightforward choice for generating sounds, It was used for:

- the beeps from the [Binatone TV Master IV](http://www.old-computers.com/museum/computer.asp?c=1035 "old-computers.com: Binatone TV Master IV"),
- the primitive, mono 1bit output of the ZX Spectrum and the IBM PC, the latter being [8254](https://en.wikipedia.org/wiki/Intel_8253 "Wikipedia: Intel 8253") driven,
- the two channel [Atari](https://en.wikipedia.org/wiki/Atari "Atari") [Television Interface Adapter (TIA)](https://en.wikipedia.org/wiki/Television_Interface_Adaptor#Noise/Tone_Generator_(AUD0/1) "Wikipedia: Television Interface Adaptor#Noise/Tone\_Generator\_(AUD0/1)") used in the [Atari 2600](https://en.wikipedia.org/wiki/Atari_2600 "Wikipedia: Atari 2600"),
- the multi-channel [General Instrument AY 3 8910](https://en.wikipedia.org/wiki/General_Instrument_AY-3-8910 "General Instrument AY 3 8910") and [Texas Instruments SN76489](https://en.wikipedia.org/wiki/Texas_Instruments_SN76489 "Texas Instruments SN76489") [PSG](https://en.wikipedia.org/wiki/Programmable_sound_generator "Wikipedia: programmable sound generator") sound chips,
- and the [Game Boy's Sharp LR35902 CPU](https://en.wikipedia.org/wiki/Game_Boy#Technical_specifications "Wikipedia: Game Boy") with integrated sound including one channel with a short user-defined waveform.

Waveforms can also be generated by composition. The next two sections compare the square and sawtooth wave to explore how the wave shape develops as more sine waves are added and how the two differ.

## Square Wave Construction

The animation below shows construction of a square wave from the addition of 10 [sine](https://en.wikipedia.org/wiki/Sine "Wikipedia: sine") waves. The overtones of a square wave occur at _odd_ multiples of the fundamental frequency, this makes it less rich in harmonics than the sawtooth wave and gives it a different sound or _[timbre](https://en.wikipedia.org/wiki/Timbre "Wikipedia: timbre")_.

It's interesting to see how the shape of the final waveform becomes more straight/perpendicular as each sine wave is added. This is still far from perfect in terms of shape with ten harmonics but likely to be a better choice for digital audio applications to prevent undesirable _[aliasing](https://en.wikipedia.org/wiki/Aliasing "Wikipedia: aliasing")_ effects.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/620/medium800thumb/circuitpython_waveform-construction-square.v2.n10.jpg?1556816430)

## Sawtooth Wave Construction

A sawtooth wave made from 10 harmonics is shown below for comparison. This one is "upside down" compared to the one that the CPX is generating but this makes no difference to the _magnitude_ of the frequencies of the harmonics.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/619/medium800thumb/circuitpython_waveform-construction-sawtooth.v2.n10.jpg?1555677080)

The wikipedia pages for [sawtooth wave](https://en.wikipedia.org/wiki/Sawtooth_wave "Wikipedia: sawtooth wave") and [square wave](https://en.wikipedia.org/wiki/Square_wave "Wikipedia: square wave") have audio clips allowing for a comparison of the two different timbres.

[Jess Swanson's An Interactive Introduction to Fourier Transforms](http://www.jezzamon.com/fourier/index.html "Jess Swanson's An Interactive Introduction to Fourier Transforms") is a fun and interactive way to explore waveforms more.

## Analogue Synthesizer Waves

The Korg Volca Bass, part of the 2010s renaissance in analogue synthesizers, offers both sawtooth and square waves as the basis for creating sounds. The dual-purpose keys which allow waveform selection are shown below for the three [(voltage controlled) oscillators (VCO)](https://en.wikipedia.org/wiki/Voltage-controlled_oscillator "Wikipedia: voltage controlled oscillators"). The synthesizer's low-pass filter can be used to reduce higher harmonics, changing the timbre of the sound. This technique is referred to as [subtractive synthesis](https://en.wikipedia.org/wiki/Subtractive_synthesis "Wikipedia: subtractive synthesis"). The opposite approach is [additive synthesis](https://en.wikipedia.org/wiki/Additive_synthesis "Wikipedia: additive synthesis") which creates sounds by adding sine waves like the animations above.

The low frequency oscillator (LFO) (below, on the left) is used to modulate the volume (amplitude) or pitch or filter cutoff frequency. This is offered in [triangle](https://en.wikipedia.org/wiki/Triangle_wave "Wikipedia: triangle wave") or square waveforms.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/687/medium800/circuitpython_korg-volca-bass-waves-straight-2000.jpg?1555847452 Korg Volca Bass wave selection for LFO and VCO. Photograph by Kevin Walters.)

The actual sawtooth wave can be seen in an example of the audio output voltage from one oscillator in the service manual, shown below. The slightly steppy quality seen here is due to the resolution of the digital oscilloscope.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/688/medium800/circuitpython_Korg-Volca-Bass-Service-Manual-waveform-output-i-800.jpg?1555885190 Korg Volca Bass service manual showing sawtooth wave output on an oscilloscope.)

On an incidental note, the Korg Volca (and Monotron) synthesizers appear to have been designed to be easily modified by their owners - [the circuit board has clearly labelled solder points](https://iamcomputo.wordpress.com/2014/01/02/korg-volca-hack-points-and-videos/ "Computo: Korg Volca Hack Points and Videos"). Hobbyist hardware modification for electronic instruments is referred to as [circuit bending](https://en.wikipedia.org/wiki/Circuit_bending "Wikipedia: circuit bending").

# Circuit Playground Express USB MIDI Controller and Synthesizer

## Going Further

## Ideas for Areas to Explore

- Make a keyboard for the CPX MIDI controller:
  - "traditional" fruit: [Circuit Playground Fruit Drums: Cirkey Cirkey](https://learn.adafruit.com/circuit-playground-fruit-drums/midi-drums#making-the-fruit-drums-6-19 "Adafruit: Circuit Playground Fruit Drums: Cirkey Cirkey"),
  - crocodile clips only: [Circuit Playground Fruit Drums: Tone Piano](https://learn.adafruit.com/circuit-playground-fruit-drums/caternuson-tone-piano "Adafruit Learn: Circuit Playground Fruit Drums: Tone Piano"),
  - conductive paint: [Bare Conductive: How to make a MIDI piano with the Touch Board](https://www.bareconductive.com/make/on-board-midi-mode/ "Bare Conductive: How to make a MIDI piano with the Touch Board") (silk screen printed, may be harded to hand paint),
  - copper tape / aluminium foil: [Wendian Jiang: Automatic Notation System with Capacitive Touch Piano](https://people.ece.cornell.edu/land/courses/eceprojectsland/STUDENTPROJ/2015to2016/wj225/wj225_report_201605230102.pdf "Wendian Jiang: Automatic Notation System with Capacitive Touch Piano") (page 6).

- Enhance the note representation on the NeoPixels to include pitch bending.
- Change the synth waveform to a sine wave, a square wave or noise made from random values (audible result may surprise).
- Write a separate program to use the onboard microphone to record and process a very short sample for use in the synthesizer.
- Use the light sensor to modulate another MIDI cc.
- Implement MIDI "poly chaining" to send notes to the next CPX board when more than one note is played simultaneously.
- Explore the capabilities of the new [audioio.Mixer](https://circuitpython.readthedocs.io/en/latest/shared-bindings/audioio/Mixer.html "CircuitPython Docs: Core Modules: audioio.Mixer") class - this could be used for limited polyphony and smoother pitch bending.
- Emulate a [Leslie speaker](https://en.wikipedia.org/wiki/Leslie_speaker "Wikipedia: Leslie speaker") by mounting your CPX synth on a servo and wiggling it.

The boards based on the Cortex M0 processor (SAMD21) like the CPX have 32kB of memory. The M4 (SAMD51) boards with 192kB like the&nbsp;[NeoTrellis M4](https://www.adafruit.com/product/4020 "Adafruit NeoTrellis M4 with Enclosure and Buttons Kit Pack") are likely to be a better choice for larger_,_ more sophisticated programs using the `adafruit_midi` library. The NeoTrellis M4 also includes stereo 12bit DACs with 3.5mm audio output.

## Related Projects

There are many projects using the [NeoTrellis M4](https://learn.adafruit.com/adafruit-neotrellis-m4 "Adafruit Learn: Neotrellis M4 Express"), the ones below are just a small selection.

### MIDI

- [Trellis M4 Expressive MIDI Controller](https://learn.adafruit.com/trellis-m4-midi-keypad-and-tilt-controller "Adafruit Learn: Trellis M4 Expressive MIDI Controller") - includes some useful background information on how MIDI works and how to use and connect iOS tablets.
- [Grand Central USB MIDI Controller in CircuitPython](https://learn.adafruit.com/grand-central-usb-midi-controller-in-circuitpython/overview "Adafruit Learn: Grand Central USB MIDI Controller in CircuitPython").
- [NeoTrellis M4 MIDI File Synthesizer](https://learn.adafruit.com/neotrellism4-midi-file-player-synthesizer "Adafruit Learn: NeoTrellis M4 MIDI File Synthesizer").

### Non-MIDI

- [Make It Sound](https://learn.adafruit.com/make-it-sound/music-and-sound-in-makecode-2 "Adafruit Learn: Make It Sound") (CircuitPython and MakeCode examples).
- [Circuit Playground Express: Piano in the Key of Lime](https://learn.adafruit.com/circuit-playground-express-piano-in-the-key-of-lime "Adafruit Learn: Circuit Playground Express: Piano in the Key of Lime").
- [Touch Tone for Circuit Playground Express](https://learn.adafruit.com/touch-tone-for-circuit-playground-express "Adafruit Learn: Touch Tone for Circuit Playground Express").
- [Circuit Playground Express: Playground Drum Machine](https://learn.adafruit.com/adafruit-circuit-playground-express/playground-drum-machine "Adafruit Learn: Circuit Playground Express: Playground Drum Machine").
- [Circuit Playground Fruit Drums](https://learn.adafruit.com/circuit-playground-fruit-drums "Adafruit Learn: Circuit Playground Fruit Drums") - this uses the Circuit Playground Classic which has _one extra_ touch-capable pad but has a smaller CPU and **_cannot run_** CircuitPython.
- [Circuit Playground Musical Glove](https://learn.adafruit.com/cpx-musical-glove "Adafruit Learn: Circuit Playground Musical Glove") - this is inspired by the&nbsp;[MINI.MU Glove Kit](https://www.adafruit.com/product/4141 "Adafruit: Pimoroni MINI.MU Glove Kit - without micro:bit") but uses MakeCode on the CPX.
- Matt Stanton's [CPX Glove Synth](https://forums.adafruit.com/viewtopic.php?f=58&t=150554 "Adafruit Forums: CPX Glove Synth code (ready-to-go synth shell)") code (C++/Arduino).

## Further Reading and Listening

- [Collin's Lab: MIDI](https://learn.adafruit.com/collins-lab-midi/video?embeds=allow "Adafruit Learn: Collin's Lab: MIDI") (YouTube video with transcript).
- [What is Web MIDI & BLE MIDI](https://learn.adafruit.com/web-ble-midi "Adafruit Learn: What is Web MIDI & BLE MIDI") (BLE=[Bluetooth Low Energy](https://en.wikipedia.org/wiki/Bluetooth_Low_Energy "Wikipedia: Bluetooth Low Energy")).
- [Gizmodo: A Beginner's Guide to the Synth](https://gizmodo.com/a-beginners-guide-to-the-synth-1736978695 "Gizmodo: A Beginner's Guide to the Synth").
- [Circuit Playground Analog Input: Analog vs. Digital](https://learn.adafruit.com/circuit-playground-analog-input/analog-vs-digital "Adafruit Learn: Circuit Playground Analog Input: Analog vs. Digital").
- [The Curious Cases of Rutherford & Fry: An Instrumental Case: Why do instruments sound different?](https://www.bbc.co.uk/programmes/m000458p "BBC Radio 4: The Curious Cases of Rutherford & Fry: An Instrumental Case: Why do instruments sound different?") (podcast, click on yellow Download button, main programme up to 00:21:30).
- [The Synthesizer Academy](http://synthesizeracademy.com/ "Scott Rise's The Synthesizer Academy") (online guides).
- [Kenny McAlpine: Bits and Pieces - A History of Chiptunes](https://global.oup.com/academic/product/bits-and-pieces-9780190496104 "Oxford University Press: Dr Kenneth B. McAlpine: Bits and Pieces - A History of Chiptunes") - a well researched book covering both the music and technology behind the Atari VCS, ZX Spectrum, Commodore 64, NES, Game Boy and more.
- [Steve W. Smith: The Scientist and Engineer's Guide to](http://www.dspguide.com/)  
[Digital Signal Processing](http://www.dspguide.com/) - an _in-depth_ book available for free online.
- [R code used to generate graphs](https://github.com/kevinjwalters/mini-projects/tree/master/controller-synth/waveforms/graphing "Github: kevinjwalters mini-projects/tree/master/controller-synth/waveforms/graphing") on the Waveforms page.

## Selected Music

- [Music From Mathematics album](https://www.discogs.com/Various-Music-From-Mathematics/release/331088 "Discogs: Various - Music From Mathematics - Decca ‎– DL 79103") (music made with [IBM 7090](https://en.wikipedia.org/wiki/IBM_7090 "Wikipedia: IBM 7090") in 1962).
- Pixelh8 (Matthew Applegate) - Obsolete? ([bandcamp](https://pixelh8.bandcamp.com/album/obsolete "Bandcamp: Pixelh8 - Obsolete?")) -&nbsp; commissioned by [The National Museum of Computing](http://www.tnmoc.org/ "The National Museum of Computing") (UK).
- [Tristan Perich](http://www.tristanperich.com/ "Tristan Perich") - [1-Bit symphony](http://www.1bitsymphony.com/ "Tristan Perich: 1-bit symphony") ([bandcamp](https://tristanperich.bandcamp.com/album/1-bit-symphony "Bandcamp: Tristan Perich - 1-Bit Symphony")).

### Adafruit NeoTrellis M4 with Enclosure and Buttons Kit Pack

[Adafruit NeoTrellis M4 with Enclosure and Buttons Kit Pack](https://www.adafruit.com/product/4020)
So you've got a cool/witty name for your band, a Soundcloud account,&nbsp;[a 3D-printed Daft Punk helmet](https://learn.adafruit.com/3d-printed-daft-punk-helmet-with-bluetooth)...&nbsp;so what could be missing from your road to stardom? The **NeoTrellis M4 Kit...**

Out of Stock
[Buy Now](https://www.adafruit.com/product/4020)
[Related Guides to the Product](https://learn.adafruit.com/products/4020/guides)
![Demo Video of Hands pressing buttons on lit up NeoTrellis M4.](https://cdn-shop.adafruit.com/product-videos/640x480/4020-00.jpg)

### Adafruit Grand Central M4 Express featuring the SAMD51

[Adafruit Grand Central M4 Express featuring the SAMD51](https://www.adafruit.com/product/4064)
Are you ready? Really ready? Cause here comes the **Adafruit Grand Central** featuring the **Microchip ATSAMD51**. This dev board is so big, it's not named after a Metro train, it's a whole freakin' _station_!

This board is like a freight...

In Stock
[Buy Now](https://www.adafruit.com/product/4064)
[Related Guides to the Product](https://learn.adafruit.com/products/4064/guides)
![Angled Shot of the Adafruit Grand Central M4 Express featuring the SAMD51.](https://cdn-shop.adafruit.com/640x480/4064-05.jpg)

### Copper Foil Tape with Conductive Adhesive - 6mm x 15 meter roll

[Copper Foil Tape with Conductive Adhesive - 6mm x 15 meter roll](https://www.adafruit.com/product/1128)
Copper tape can be an interesting addition to your toolbox. The tape itself is made of thin pure copper so its extremely flexible and can take on nearly any shape. You can easily solder to it, and the tape itself can carry current just like a wire. On the back is an electrically conductive...

In Stock
[Buy Now](https://www.adafruit.com/product/1128)
[Related Guides to the Product](https://learn.adafruit.com/products/1128/guides)
![Angled Shot of the Copper Foil Tape with Conductive Adhesive - 6mm x 15 meter roll.](https://cdn-shop.adafruit.com/640x480/1128-04.jpg)

### Copper Foil Tape with Conductive Adhesive - 25mm x 15 meter roll

[Copper Foil Tape with Conductive Adhesive - 25mm x 15 meter roll](https://www.adafruit.com/product/1127)
Copper tape can be an interesting addition to your toolbox. The tape itself is made of thin pure copper so its extremely flexible and can take on nearly any shape. You can easily solder to it, and the tape itself can carry current just like a wire. On the back is an electrically conductive...

In Stock
[Buy Now](https://www.adafruit.com/product/1127)
[Related Guides to the Product](https://learn.adafruit.com/products/1127/guides)
![Angled Shot of the Copper Foil Tape with Conductive Adhesive - 25mm x 15 meter roll.](https://cdn-shop.adafruit.com/640x480/1127-04.jpg)

# Circuit Playground Express USB MIDI Controller and Synthesizer

## MIDI Controller

![](https://cdn-learn.adafruit.com/assets/assets/000/074/438/medium800/circuitpython_cpx-over-flatpianokeys-2400.jpg?1555146725)

Download the `cpx-expressive-midi-controller.py` file with the link below. Plug your Circuit Playground Express (CPX) into your computer via a known-good USB data cable. A flash drive named CIRCUITPY should appear in your file explorer/finder program. Copy&nbsp;`cpx-expressive-midi-controller.py` to the **CIRCUITPY** &nbsp;drive, renaming it [code.py](https://learn.adafruit.com/welcome-to-circuitpython/the-circuitpy-drive "Adafruit: Welcome to CircuitPython! The CIRCUITPY Drive").

Scroll past the code below for two videos showing the CPX controlling some synthesizers and a discussion on selected parts of the program.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Circuit_Playground_Express_USB_MIDI/cpx-expressive-midi-controller/code.py

## MIDI Controller Examples

The first video below shows the program running on a CPX board controlling [Nikolay Tsenkov's Viktor NV-1 free software synthesizer](https://nicroto.github.io/viktor/ "Viktor NV-1 Web MIDI synthesizer"). Note the movement of the pitch wheel and modulation wheel just left of the keyboard.

https://youtu.be/O-VdYYtkbyM

The second video uses the CPX to control the Gakken Pocket Miku (NSX-39) synthesizer. This synthesizer is normally used for its&nbsp;[Vocaloid](https://en.wikipedia.org/wiki/Vocaloid "Wikipedia: Vocaloid")&nbsp;functionality but here MIDI channel 2 is being used for its [General MIDI](https://en.wikipedia.org/wiki/General_MIDI "Wikipedia: General MIDI") implementation of a piano, part of its [Yamaha XG](https://en.wikipedia.org/wiki/Yamaha_XG "Wikipedia: Yamaha WG")&nbsp;functionality.

https://youtu.be/ToPUT17Vtxk

## Code Discussion

The main part of the program is a loop which sends certain MIDI messages based on various inputs, like:

- a change in touching of the touch pads which causes **note on** or **note off** messages to be sent,
- any significant change in accelerometer `x` and `y` values which sends **pitch bend change** or **change control** messages, these are limited by rate and inhibited by the switch in right position.

The loop also checks the button and switch values. These are used to change octave/semitone range and scale (between major and chromatic modes).

The program starts with a major scale at middle C. The touch pad at the top left of CPX will initially send a C<sub>4 </sub>(MIDI note 60) and next one (counterclockwise) will send a D<sub>4</sub> (MIDI note 62) and so on. The code excerpt below shows this code, the MIDI note values for each touch pad are stored in `midi_notes[idx]`, these are based on the middle C value plus offset per scale. This is further adjusted by the current `octave` and `semitone` offset selected - a comment informs us of the significance of the "[magic value](https://en.wikipedia.org/wiki/Magic_number_(programming) "Wikipedia: magic number (programming)")" of 12. The semitone offset can be used to change the key or in chromatic scale to offset a second CPX by +7 semitones to allow two CPXs with 14 notes to cover just over a full octave.

```auto
for idx, touchpad in enumerate(touchpads):
    if touchpad.value != keydown[idx]:
        keydown[idx] = touchpad.value
        # 12 semitones in an octave
        note = midi_notes[idx] + octave * 12 + semitone
        if keydown[idx]:
            midi.send(NoteOn(note, velocity))
            noteLED(pixels, note, velocity)
        else:
            midi.send(NoteOn(note, 0))  # Using note on 0 for off
            noteLED(pixels, note, 0)
```

The `keydown` list is tracking the previous state of the touchpad. This is needed to avoid sending unnecessary duplicate MIDI messages if nothing has changed.

One surprise may be the use of **note on** message for the user lifting their finger from the touch pad. When velocity is set to 0 this becomes equivalent to a **note off** for most MIDI devices. This is a useful memory economisation on an M0 processor-based board as each message is a separate python class and these consume memory when they are `import`'ed. The technique for importing the library with only the messages needed is shown below.

```auto
import adafruit_midi

from adafruit_midi.note_on          import NoteOn
from adafruit_midi.control_change   import ControlChange
from adafruit_midi.pitch_bend       import PitchBend
```

When a button is used to change a value the new value is shown by briefly flashing a NeoPixel white a few times with the `flashLED()` function and then restoring the NeoPixel to its previous value.

```auto
# white pulse used to indicate octave changes
flashbrightness = 20
def flashLED(pix, position):
    pos = position % numpixels
    t1 = time.monotonic()
    oldcolour = pix[pos]
    while time.monotonic() - t1 < 0.25:
        for i in range(0, flashbrightness, 2):
            pix[pos] = (i, i, i)
        for i in range(flashbrightness, 0, -2):
            pix[pos] = (i, i, i)
    pix[pos] = oldcolour
```

This code works but it's worth discussing some minor issues with it. The `while` loop is running for a quarter (`0.25`) of a second, this would be more flexible if it was a function argument with a default value. The same could be said for the global variable `flashbrightness`. This would also make it easier to test.

Perhaps more importantly, inside the `while` loop there are two `for` loops which ramp the brightness of `pix[pos]` up and then down. These are not constrained by time but happen to execute at a desirable rate on the CPX board. This means the flashing rate of the NeoPixel is subject to the performance of the CircuitPython interpreter, the `neopixel` library and the processor - changes to any of those could alter the flash rate. A board using the faster M4 processor will inevitably make this flash much faster.

The code which sends the **control change** message is shown below. The `scale_acc()` [function](https://learn.adafruit.com/circuitpython-101-functions/what-are-functions "CircuitPython 101: Functions: Function Basics") is taking the accelerometer's `ay` (in [ms-2](https://en.wikipedia.org/wiki/Metre_per_second_squared "Wikipedia: metre per second squared")) value and turning it into an integer value between 0 and 127. The `acc_nullzone` variable (set to `1.3`) keeps the value at 0 even when the board isn't quite flat or is gently nudged. The `acc_range` variable (set to `4.0`) determines the end of the range. i.e. an `ay` value of `acc_nullzone + acc_range` will return 127. It might be more natural to calculate and use the angle of the board instead of `ay`, but with the current ranges the movement feels appropriate for the modulation output. The use of `abs()` on the `scale_acc()` return value makes forward and backward tilt equivalent.

```auto
# scale from 0 to 127 (maximum cc 7bit value)
new_mod_wheel = abs(scale_acc(ay, acc_nullzone, acc_range, 127))
if (abs(new_mod_wheel - mod_wheel) > min_mod_change
        or (new_mod_wheel == 0 and mod_wheel != 0)):
    midi.send(ControlChange(midi_cc_modwheel, new_mod_wheel))
    mod_wheel = new_mod_wheel
```

The `if` statement is determining whether the value has changed by a significant amount since the last value was sent. The value of 0 will always be sent to allow the modulation wheel to return to exactly 0 which often equates to no modulation.

The checks and message sending code for **control change** and **pitch bend change** &nbsp;messages are wrapped in an `if` statement to ensure they are only sent at a maximum frequency, currently fixed at 10Hz. This keeps the MIDI message rate to a low rate suitable for all devices. This could be increased or made controllable but care would be needed to ensure the accelerometer readings are not noisy and give smooth variations.

The code for switch and button handling is getting a little lengthy and making the contents of the main `while` loop rather large. This can be a bit of a trap as further small additions accumulate and the code can get larger and larger. This can lead to a segment of code that's difficult to understand and more likely to be or become buggy. Moving some of the code into one or more functions is likely to make the code less unwieldy and more [maintainable](https://en.wikipedia.org/wiki/Software_maintenance "Wikipedia: software maintenance").

## Capacitive Touch
Info: 

From [CircuitPython Cap Touch](https://learn.adafruit.com/circuitpython-essentials/circuitpython-cap-touch#main-loop-10-6 "CircuitPython Essentials: CircuitPython Cap Touch"):

> If you get too many touch responses or not enough, reload your code through the serial console or eject the board and tap the reset button!

It's interesting to note that capacitive keyboards are far from a new invention. From the book [Analog Days](http://www.hup.harvard.edu/catalog.php?isbn=9780674016170 "HUP: Analog Days"), referring to early 1960s [Buchla 100 Series](http://www.vintagesynth.com/misc/buchla100.php "Vintage Synth Explorer: Buchla 100 Series"):

> "They [the ports] were all capacitance-sensitive touch-plates, or resistance-sensitive in some cases, organized in various sorts of array.
> 
> "I saw no reason to borrow from a keyboard, which is a device invented to throw hammers at strings, later on, for operating switches for electronic organs and so-on."
> 
> [Don Buchla](https://en.wikipedia.org/wiki/Don_Buchla "Wikpedia: Don Buchla")

## MIDI routing

MIDI messages between different USB devices are not automatically forwarded by the operating system. An application is required to forward or route the messages. Tommy van Leeuwen has written a very useful [Web MIDI Sequencer, Router & Drum Machine](http://midi.tomarus.io/ "Tommy van Leeuwen's Web MIDI Sequencer, Router & Drum Machine") application which can be used for this.

[Web MIDI](https://www.midi.org/articles/about-web-midi "MIDI Manufactuer's Association: Web MIDI") allows browser-based applications to communicate with MIDI devices. [Web MIDI is only implemented](https://caniuse.com/#feat=midi "Can I Use: Web MIDI API") in some browsers, for example Chrome and Opera.

The example in the video above shows the `CircuitPython MIDI`'s channel **1** being sent to the `NSX-39`'s channel **2**.

The example in the screenshot below shows an `Axiom 25 MIDI In`'s channel **1** being sent to the `CircuitPython MIDI`'s channel **1**.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/529/medium800/circuitpython_midi.tomarus.io-router-example-largenwide-trimmed.png?1555451597 Router panel of http://midi.tomarus.io/ Web MIDI sequencer.)

## Synthesizers

Everyone needs a synthesizer! If you don't have an EMS Synthi A at hand (picture below), there's a useful list of _software_ synthesizers on [Trellis M4 Expressive MIDI Controller guide](https://learn.adafruit.com/trellis-m4-midi-keypad-and-tilt-controller/synthesizers "Adafruit: Trellis M4 Expressive MIDI Controller") including some free ones.

[MuTools MuLab](http://www.mutools.com/ "MuTools") is another&nbsp;[digital audio workstation (DAW)](https://en.wikipedia.org/wiki/Digital_audio_workstation "Wikipedia: digital audio workstation") which can be used in a restricted mode for free.

[Plogue chipsounds](https://www.plogue.com/products/chipsounds.html "Plogue Art et Technologie - chipsounds") is a [VST plugin](https://en.wikipedia.org/wiki/Virtual_Studio_Technology "Wikipedia: Virtual Studio Technology") and standalone synthesizer with meticulous recreations of 1970s and 1980s era sound chips. It can be used for 4 minutes per session for free.

![](https://cdn-learn.adafruit.com/assets/assets/000/074/689/medium800/circuitpython_every-nun-needs-an-ems-synthi-advert-trimmed.jpg?1556391450 EMS advertisement for a Synthi A synthesizer from the 1970s.)

The next page has a program for a basic synthesizer for the CPX.

# Circuit Playground Express USB MIDI Controller and Synthesizer

## Basic Synthesizer

![](https://cdn-learn.adafruit.com/assets/assets/000/074/439/medium800/circuitpython_cpx-over-midi-controller-2400.jpg?1555146769)

Download the `cpx-basic-synth.py` file with the link below and copy it to the **CIRCUITPY** drive renaming it [code.py](https://learn.adafruit.com/welcome-to-circuitpython/the-circuitpy-drive "Adafruit: Welcome to CircuitPython! The CIRCUITPY Drive").

Scroll past the code below for a discussion on selected parts of the program and a video showing the CPX synthesizer being controlled by another CPX.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Circuit_Playground_Express_USB_MIDI/cpx-basic-synth/code.py

## Basic Synthesizer Example

The video below shows one CPX running the MIDI Controller program from the previous page and the second running the synthesizer code on this page. Tilting to the left (or right) bends the pitch and tilting up or down increases the mod wheel.

https://youtu.be/y7-8YtpcxRc

The video shows the limitations of the approach for pitch bending. There's a very perceivable delay when the sample is played at a new sample rate to change the frequency. This gives the pitch bend a certain unpleasant choppiness and means it can lag behind a rapid burst of **pitch bend change** messages. Attempts at [portamento](https://en.wikipedia.org/wiki/Portamento "Wikipedia: Portamento") are going to sound like a low quality [glissando](https://en.wikipedia.org/wiki/Glissando "Wikipedia: glissando")!

A compiled, mid-level language like C is less easy to use than Python but can offer faster, more predictable performance and often allows more direct control over the audio hardware. The&nbsp;[Soulsby miniATMEGATRON](https://soulsbysynths.com/miniatmegatron/ "Soulsby miniATMEGATRON")&nbsp;shows what can be done with C code using an Arduino Uno based on the slower ATmega328P processor and an external [low-pass filter](https://en.wikipedia.org/wiki/Audio_filter "Wikipedia: audio filter").

## Code Discussion

The main part of the program is a loop checking for any incoming MIDI messages and acting on these. At the end of the loop it applies an innovative form of crude amplitude modulation by rapidly disabling/enabling the speaker. The MIDI message actions are:

- **note on -** plays a pre-constructed sample at a sample rate which matches the note's pitch and a volume which approximates the note's velocity, note pitch is shown on the NeoPixels,
- **note off -** ends playing of the current sample and turns off the NeoPixel,
- **pitch bend change** - if a note is playing then the sample rate is adjusted for the new value of pitch bend,
- **control change** for cc1 - this represents the mod wheel and is used to control the duty cycle of the amplitude modulation for speaker output.

The sample used to play the note is a short list of values representing a sawtooth wave. The short length makes it low resolution and gives it a "steppy" appearance, see the next page for an in-depth look at waveforms. This single cycle wave is generated for a small range of volumes before the program's main loop with the code below. This pre-calculation uses a bit more memory but minimises the time it takes (latency) to start playing a note.

```auto
def waveform_sawtooth(length, waves, volumes):
    for vol in volumes:
        waveraw = array.array("H",
                              [midpoint +
                               round(vol * sawtooth((idx + 0.5) / length
                                                    * twopi
                                                    + math.pi))
                               for idx in list(range(length))])
    waves.append((audioio.RawSample(waveraw), waveraw))
    
waveform_by_vol = []
waveform_sawtooth(sample_len,
                  waveform_by_vol,
                  [10362, 14654, 17947, 20724, 23170,
                   25381, 27415, 29308, 31086, 32767])
```

The list of numbers representing volumes has been generated externally with:

```auto
n=10
[round(math.sqrt(x) / math.sqrt(n) * 32767)
 for x in range(1, n + 1)]
```

The numbers are not evenly spaced because they represent the maximum _amplitude_ of the wave which is output as a voltage. If the voltage is doubled, then broadly speaking the current will double and since [power is the product of these two quantities](https://learn.adafruit.com/multimeters/current "Adafruit Learn: Multimeters: Current") the power will _quadruple_. This explains the role of the `math.sqrt()` to provide amplitudes which represent a linear increase in power. These will correspond to an increase in volume ([sound pressure level](https://en.wikipedia.org/wiki/Sound_pressure#Sound_pressure_level "Wikipedia: sound pressure")) when the velocity of a note is mapped linearly to a list element.

The [array](https://circuitpython.readthedocs.io/en/3.x/docs/library/array.html "CircuitPython: Docs: MicroPython libraries: array – arrays of numeric data") type used for samples is a compact representation for numbers. ["H"](https://docs.python.org/3/library/array.html "Python 3: Documentation: The Python Standard Library: Data Types: array") selects unsigned 16 bit integers which is the representation [most closely matching the native DAC values](https://forums.adafruit.com/viewtopic.php?f=60&t=150894 "Adafruit Forums: CircuitPython and MicroPython: What is the best array type for audioio.RawSample()?")&nbsp;- this helps with memory efficiency.

The NeoPixels are used to show the note playing with the `noteLED()` function shown below.

```auto
# Turn NeoPixel on to represent a note using RGB x 10
# to represent 30 notes - doesn't do anything with pitch bend
def noteLED(pix, pnote, pvel):
    note30 = (pnote - midi_note_C4) % (3 * numpixels)
    pos = note30 % numpixels
    r, g, b = pix[pos]
    if pvel == 0:
        brightness = 0
    else:
        # max brightness will be 32
        brightness = round(pvel / 127 * 30 + 2)
    # Pick R/G/B based on range within the 30 notes
    if note30 < 10:
        r = brightness
    elif note30 < 20:
        g = brightness
    else:
        b = brightness
pix[pos] = (r, g, b)
```

[Modular division](https://en.wikipedia.org/wiki/Modular_arithmetic "Wikipedia: modular arithmetic") is used to map the note to 30 values, the first ten notes will be red starting at middle C ( **C<sub>4</sub>** ), the next ten green, the next ten blue and this then repeats both above and below that range. Multiple values will be merged, e.g. **C<sub>4</sub>** and **A#<sub>4 </sub>** keys pressed together will show as [yellow](https://en.wikipedia.org/wiki/Secondary_color#Additive_secondaries "Wikipedia: secondary color").

The NeoPixels have been created with `brightness=1.0`. For the current library implementation this makes updates faster and uses less memory. This explains why the maximum value based on the note's velocity is set to just 32 and not the maximum value, 255.

The same `noteLED()` is used in the MIDI controller. The code could be kept in a separate file and that could be `import`'ed. This would make the code easier to maintain, promote [reusability](https://en.wikipedia.org/wiki/Reusability "Wikipedia: reusability") and is a step towards creating a&nbsp;[library](https://en.wikipedia.org/wiki/Library_(computing) "Wikipedia: library (computing)").

At the end of the main loop is the code that applies amplitude modulation to the speaker output (only).

```auto
if mod_wheel > 0:
        t1 = time.monotonic() * am_freq
        # Calculate a form of duty_cycle for enabling speaker for crude
        # amplitude modulation. Empirically the divisor needs to greater
        # than 127 as can't hear much when speaker is off more than half
        # 220 works reasonably well
        new_speaker_on = (t1 - int(t1)) > (mod_wheel / 220)
    else:
        new_speaker_on = True
```

Any MIDI **control change** values received for cc1 are stored in the&nbsp;`mod_wheel` variable. For non-zero values this is used to control when the speaker is on or off. The time measurement is used to set a regular period of on and off with `am_freq` set to a fixed value of 16 (Hz). The `mod_wheel` value then determines the duration of the off part. In synthesis terminology, this would be referred to as a free-running, square wave [LFO](https://en.wikipedia.org/wiki/Low-frequency_oscillation "Wikipedia: low frequency oscillation") modulating the amplitude with maximum depth with the mod wheel determining the duty cycle.

## External Audio

The CPX can be connected from touchpad **A0** to an amplifier or headphones but cannot drive a&nbsp;[loudspeaker](https://en.wikipedia.org/wiki/Loudspeaker "Wikipedia: loudspeaker")&nbsp;without amplification. Using amplified speakers or a pair of headphones, connect your Circuit Playground Express as shown below. The speakers from Adafruit have a volume knob for easy adjustment. You can use a cell phone wall charger, computer, or cell phone external battery to power the speakers (and the Circuit Playground Express).

![](https://cdn-learn.adafruit.com/assets/assets/000/075/411/medium800/microcontrollers_circuitpython_circuit_playground_hp.png?1557323363)

### USB Powered Speakers

[USB Powered Speakers](https://www.adafruit.com/product/1363)
Add some extra boom to your audio project with these powered loudspeakers. We sampled half a dozen different models to find ones with a good frequency response, so you'll get quality audio output for music playback. Simply connect the standard 3.5mm stereo plug into your Raspberry Pi model...

In Stock
[Buy Now](https://www.adafruit.com/product/1363)
[Related Guides to the Product](https://learn.adafruit.com/products/1363/guides)
![Two square-ish USB Powered Speakers](https://cdn-shop.adafruit.com/640x480/1363-07.jpg)

### Small Alligator Clip Test Lead (set of 6)

[Small Alligator Clip Test Lead (set of 6)](https://www.adafruit.com/product/4100)
Connect this to that without soldering using these small&nbsp;alligator clip test leads. 18" long cables with color-coded alligator clips on both ends. You get 6 pieces in 6 unique colors. Strong and grippy, these always come in handy! We often use these in conjunction with a multimeter...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4100)
[Related Guides to the Product](https://learn.adafruit.com/products/4100/guides)
![Bundle of Small Alligator Clip Test Lead - set of 6](https://cdn-shop.adafruit.com/640x480/4100-01.jpg)

### USB Battery Pack for Raspberry Pi - 10000mAh - 2 x 5V outputs

[USB Battery Pack for Raspberry Pi - 10000mAh - 2 x 5V outputs](https://www.adafruit.com/product/1566)
A large-sized rechargeable battery pack for your [Raspberry Pi](http://www.adafruit.com/raspberrypi) (or [Arduino](http://www.adafruit.com/arduino), or [Propeller](http://www.adafruit.com/category/26), or anything else that uses 5V!). This pack is intended for...

In Stock
[Buy Now](https://www.adafruit.com/product/1566)
[Related Guides to the Product](https://learn.adafruit.com/products/1566/guides)
![Angled shot of white rectangular USB battery pack with 4 dotted lights indicating battery is fully charged. ](https://cdn-shop.adafruit.com/640x480/1566-11.jpg)


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### USB A/Micro Cable - 2m

[USB A/Micro Cable - 2m](https://www.adafruit.com/product/2185)
This is your standard USB A-Plug&nbsp;to Micro-USB cable. It's 2 meters long so you'll have plenty of cord to work with for those longer extensions.

In Stock
[Buy Now](https://www.adafruit.com/product/2185)
[Related Guides to the Product](https://learn.adafruit.com/products/2185/guides)
### Circuit Playground Express - Base Kit

[Circuit Playground Express - Base Kit](https://www.adafruit.com/product/3517)
It's the **Circuit Playground Express Base Kit!** &nbsp;It provides&nbsp;the few things you'll need to get started with the new [Circuit Playground Express](https://www.adafruit.com/product/3333).&nbsp;This version of Circuit Playground is super powered, and will...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3517)
[Related Guides to the Product](https://learn.adafruit.com/products/3517/guides)
### Circuit Playground Express Advanced Pack

[Circuit Playground Express Advanced Pack](https://www.adafruit.com/product/2769)
 **Circuit Playground Express** &nbsp;is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to program....

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

[USB Powered Speakers](https://www.adafruit.com/product/1363)
Add some extra boom to your audio project with these powered loudspeakers. We sampled half a dozen different models to find ones with a good frequency response, so you'll get quality audio output for music playback. Simply connect the standard 3.5mm stereo plug into your Raspberry Pi model...

In Stock
[Buy Now](https://www.adafruit.com/product/1363)
[Related Guides to the Product](https://learn.adafruit.com/products/1363/guides)
### Small Alligator Clip Test Lead (set of 6)

[Small Alligator Clip Test Lead (set of 6)](https://www.adafruit.com/product/4100)
Connect this to that without soldering using these small&nbsp;alligator clip test leads. 18" long cables with color-coded alligator clips on both ends. You get 6 pieces in 6 unique colors. Strong and grippy, these always come in handy! We often use these in conjunction with a multimeter...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4100)
[Related Guides to the Product](https://learn.adafruit.com/products/4100/guides)
### USB Battery Pack for Raspberry Pi - 10000mAh - 2 x 5V outputs

[USB Battery Pack for Raspberry Pi - 10000mAh - 2 x 5V outputs](https://www.adafruit.com/product/1566)
A large-sized rechargeable battery pack for your [Raspberry Pi](http://www.adafruit.com/raspberrypi) (or [Arduino](http://www.adafruit.com/arduino), or [Propeller](http://www.adafruit.com/category/26), or anything else that uses 5V!). This pack is intended for...

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

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [DIY Circuit Playground Shields](https://learn.adafruit.com/circuit-playground-shields.md)
- [Circuit Playground Express Spinner Game in MakeCode](https://learn.adafruit.com/circuit-playground-makecode-spinner-game.md)
- [Circuit Playground Express Rocket Lamp](https://learn.adafruit.com/cpx-rocket-lamp.md)
- [Make It Sound](https://learn.adafruit.com/make-it-sound.md)
- [Circuit Playground Express Compass](https://learn.adafruit.com/circuit-playground-express-compass.md)
- [Circuit Playground Hot Potato](https://learn.adafruit.com/circuit-playground-hot-potato.md)
- [Mu Keyboard Shortcut Cheat Sheets](https://learn.adafruit.com/mu-keyboard-shortcut-cheat-sheets.md)
- [Mason Jar Snow Globe](https://learn.adafruit.com/snow-globe-makecode.md)
- [Lucky Cat with Circuit Playground Express](https://learn.adafruit.com/lucky-cat-with-circuit-playground-express.md)
- [Custom Controllers for MakeCode Arcade](https://learn.adafruit.com/custom-controllers-for-makecode-arcade.md)
- [Epoxy Resin Torch Lamp with Touch Control & 3D Printed Base](https://learn.adafruit.com/epoxy-resin-torch-lamp-with-touch-control-3d-printed-base.md)
- [MIDI Stomping Pads](https://learn.adafruit.com/midi-stomping-pads.md)
- [Make It Shake, Rattle, and Roll: Accelerometer Use](https://learn.adafruit.com/make-it-shake-rattle-and-roll.md)
- [Secret Hollow Book Intrusion Detector](https://learn.adafruit.com/secret-hollow-book.md)
