Controlling an analog guitar effect with an app over BLE

Enrique Ramírez
6 min readMay 18, 2022

A few years ago, I wrote a medium post on how to control a digital potentiometer over Bluetooth Low Energy, BLE, with an Android app. That code is a bit obsolete, specially on the Android part, as the code practices and libraries have changed massively since then. It though it was a good time to write a more updated version of it and taking the practicality of it a bit further.

What I wanted to do in this case was taking a classic guitar effect circuit and replace the potentiometers with digital ones so I could add a digital interface and enjoy the best of both worlds, which are the analogue sound on one side and the digital control capabilities which are endless on the other side.

The Hardware

The pedal I choose was the famous fuzz distortion RAT created by ProCo. I was familiarised with this circuit as I had built a clone of this pedal in the past and it has the advantage that all the potentiometers in it have the same value, which is 100KΩ.

ProCo RAT Fuzz Distortion

Not getting too deep into the effect itself, it is a classic circuit that could be divided into 3 stages for the signal path with their corresponding potentiometer:

  • Clipping stage. This part amplifies the signal with an op amp against 2 diodes, normally inverted, which clip the signal in a way that it produces that fuzzy sound. The potentiometer in this stage controls the gain/distortion.
  • Tone control. This is just a variable low pass filter. The potentiometer moves the cut off frequency.
  • Output Stage. Output amplification made with a FET transistor. The potentiometer here changes the output volume without any clipping involved.
RAT schematic from ElectroSmash.com

As mentioned before, all this pots have the same value so I looked for an IC containing multiple digital pots of the same value.

Digitpot

The digipot IC I initially choose was the MCP4361 from Microchip. This Ic contains 4 pots controlled by the same SPI interface with 256 taps each.

MCP4361 Layout

This IC also have the advantage of having non volatile memory that allows reading and writing of potentiometer value as well as saving the value when switching off the device.

This is what the schematic looks like after adding the digital pots:

Digipot based RAT schematic

I added a set of jumper pins to easily connect to a microcontroller using jump wires, but also added a JST connector to be able to connect to some audio jack boards that I created for these kind projects. And finally added pins for potentiometer 3 which is not in use in the circuit but can be used for testing purposes.

And with a little bit of component placement and routing we get a prototype PCB ready to be produced.

Digpot RAT PCB

MCU

Now we have an analogue circuit with a digitally over SPI. I initially thought of using a Raspberry PI or a similar board that would allow you to do a web based interface or even add a touchscreen, but I decided to use an Arduino based board with BLE capabilities as I already used for previous projects and could allow me adding a simple app to be able to demo it easily.

This board is the Adafruit Feather nRF52840 which I used in a previous project where I explained how to set up this board to be able to read the value of a moisture sensor by defining a BLE service and characteristics. It took this project even further away adding actuators, but I never documented the output results.

This case is similar except that we define 3 BLE characteristics to be able to read and write the value of the digital potentiometers and we build an SPI communication to pass or read this values from the Digipot IC.

The final assembly looks something like:

Digipot RAT diagram

The Software

At this point, we just need some code that let us control these digital potentiometers.

MCU programing

The Adafruit Feather nRF52840 is an Arduino based board, therefore we can use all Arduino libraries in addition to the Adafruit libraries that make BLE programing easier.

Without getting too much into the detail, what we require is the following:

  • BLE setup.
  1. Define a custom GATT service for our remotely controllable pedal.
  2. Define the BLE Characteristics for the 3 parameters (gain, tone and volume), or 4 if we want to include testing potentiometer 3. These characteristics should have read and write capabilities.
  3. Service advertising
  • Characteristic writing callback creation, that triggers the sending of data over SPI.

We are assuming that the values sent are form 0 to 255, which are the taps of our potentiometer. This is an example for one of the 3 callbacks.

  • SPI communication for writing the values to the digital pots.
  • SPI communication for the reading of digipot values.

In this first version I didn’t implement reading of the values, but it would be similar with different commands. Another thing to consider here is whether you want to do a reading every time a characteristic is read or do an initial one, and then keeping a state with the value of the digital pots that would be modified on every write.

The full code can be found on this github repository.

Android app

It is not necessary to build an app in order to control this BLE interface as there are generic apps that let you read and write data into BLE powered devices, but I wanted to make something cool for a later demo so I implemented an Android app.

I have not yet published the code for it, a it not the cleanest, but it is worth mentioning the I have used the Jetpack Compose library for the UI creation.

This is what the app looks like.

Screenshot of the MICE (Digipot RAT) app

In essence it is a simple app that connects to the BLE device when you tap the “footswitch” button, reads the current value of all parameters, reflecting in the UI, and send new values when the user change the potentiometers.

It is worth mentioning that the value of the UI digipot is in the range of 0 to 1, stored as float number, which later is transformed into a byte that can take values from 0 to 255. And as a last thing, when testing, I realised that the potentiometers were suppose to be audio type (exponential) rather than lineal, which is common in guitar pedals, so I also made a quick function to change that.

Demo

After testing and doing some quick changes, I recorded a demo of this project. The MCP4361 IC wasn’t properly soldered as I am not very good with SMD soldering, so I replaced it with the MCP41100 with I had used in the past. I made an auxiliary board with 3 ICs of this model, the code shared actually reflects this change, but my plan is to add the original digipot and re-record the demo. In the meantime, I hope that you enjoy this first demo.

--

--