Let’s Program Your Big Muff

Now that the digital pot is able to control the distortion, the Big Muff is capable of tremolo. Actually, it is now only capable of tremolo and does not have much in the way of control. In part two of the Big Muff mod, I will walk through changes that I have implemented and had a lot of fun with. Read on to see how I set tempo and depth controls.

Prerequisite Knowledge

While you could certainly copy and paste and have a cool pedal modification, I strongly recommend that you brush up on a few concepts before diving off into this part of the process.

  • AnalogRead()
  • DigitalWrite()
  • micros() vs millis()
  • debouncing buttons

Let’s Begin

In my previous post I basically just implemented Collin Cunningham’s tremolo project. As much as I loved it, something about the project bothered me. I realize that the purpose of the video was to create interest in concept and motivate viewers into taking things further, but it made me crazy that the original Sustain pot was left just sitting around. It also bothered me that the tremolo effect pulsed from full off to full on and that the only control for the rate of pulsing was by way of an additional pot being read by the Arduino. What I have done here is really an effort to quiet my mind a little bit and tie up what feel to me to be loose ends.

In these next steps, I modify the project in these ways:

  1. Tempo Tap
  2. Depth Control
  3. Effect Toggle

Tempo Tap

One of my favorite features in a classic tremolo effect pedal is the ability to set the tempo by way of an external footswitch or tap switch. Adding one to this build was complicated by the limitation of the Arduino loop, but I created a clever threading workaround that should be flexible enough to be utilized in a lot of projects. Let me define the problems I had to overcome.

Tempo PedalFirst, the tempo must be set by measuring the actual time between taps on a pedal. This is complex because certain operations (reading the value of our pots, for instance) take processing cycles and effectively delay the programming loop within the Arduino. Second, the original project code sets the rate of the tremolo effect by pausing code execution using the delay() method. This is logical in the scope of what that project was achieving, but I want more control. I want realtime tempo-setting and delaying execution exacerbates the already troubling Arduino timing problem. Third, I need a way to stop averaging tap samples. Consider this: If I tap 120 beats per minute and then the tempo of the song changes, I need to tap a different tempo. I need a way to “forget” the 120 BPM so that my new tempo can be accurate.

Ok, so these are my problems. Now, here are my solutions.

Tempo Listener

First, after thinking the timing issue through for a while I came to a conclusion; I need a method to calculate the actual passage of time between taps on the pedal. This part is relatively simple, but the second problem listed above complicates things. If I pause my code in order to set the rate of tremolo, I also pause my tempo “listener.” This means that I will actually solve this problem in a later step. For now I just set up the listener. The listener looks like this:

int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
 lastDebounceTime = millis();
if ((millis() - lastDebounceTime) > debounceDelay) {
 if (reading != buttonState) {
 buttonState = reading;
// checking TEMPO
 if (buttonState == HIGH) {
 sum += 60000 / (lastDebounceTime - previousBeat);
 BPM = sum / beatCount;
 checkInterval_1 = checkInterval_2 = (long)(0.00390625 * (float)(60000000L / (long)BPM)); // updates the output wave 256 times a beat.
 previousBeat = lastDebounceTime;
// If the pedal is unused for a while, reset tempo checking
 if ((millis() - lastDebounceTime) > resetThreshold) {
 previousBeat = beatCount = sum = 0;

Essentially, this code checks the time in millisecond each time the pedal is tapped. It then sums the intervals and divides them by the total number of beats. This beat is them used to determine how quickly to load the next index of the array into the digital pot using the variable CheckInterval_1. If you are following along, I recommend setting up an LED to blink on the BPM and do not use the Serial.println() that is so easy to use normal. Outputting to serial slows the execution WAY down and makes setting a tempo impossible.

Tempo Writer

Now, once the tempo is being set properly we need to output to the digital pot based on the new tempo. This will be handled in two parts: the function and the call to the function.

bool checkSustainCycle() {
 lastCheck_1 = micros();
 if (lastCheck_1 >= checkThreshold_1) {
 checkThreshold_1 += checkInterval_1;
 return true;
 return false;

This function just quickly checks to see if the current time in microseconds equals or exceeds the interval at which we need to update the pot. If it is at or beyond the threshold, we get a TRUE value otherwise we get a FALSE. Great! so how do we use that?

if (checkSustainCycle()) {
 sustainResistance = sineTable[i]*((float)(sustainValue+1)/1024); // CHANGE "sineTable" TO "squareTable", "sawTable", OR "sawrevTable"

There it is! If the interval check determine that it is time to update we jump in and set the new pot resistance, otherwise we skip on down.

Tempo Reset

The last problem was the need to reset the tempo memory. I have already posted this one above, so if you were paying attention you already know what I’m about to say.

long resetThreshold = 4000;
// If the pedal is unused for a while, reset tempo checking
 if ((millis() - lastDebounceTime) > resetThreshold) {
 previousBeat = beatCount = sum = 0;

And that is all there is to it. If the pedal sits around for 4 seconds in my case, the beat and beatCount and sum all reset to zero which allows the next round of taps to average correctly.

Depth Control and Effect Toggle

Pot WiringTempo works great now, but I still have the issue of depth control. I personally don’t like spanning the entire range of distortion if I have a method by which to customize things. It just so happens that the original pot is still sitting around as well which, if you remember, was another peeve of mine. Here is how I added the pot back into the circuit for controlling the depth of the tremolo.

As pictured, I am send that middle lug back to the Arduino so that it can be read on Analog zero.  Now I need a switch to tell the Arduino if the pot is just controlling the depth of the tremolo or simply passing its value to the digital pot. The code can then be altered as follows.

 if(sustainState == 1) {
 if (checkSustainCycle()) {
 sustainResistance = sineTable[i]*((float)(sustainValue+1)/1024); /
 sustainResistance = ((sustainValue)/4);

Here you can see that I check the sustainState to see if the switch is open or closed. If closed (or ON) we cycle through the wavetable to create the tremolo effect otherwise we set the resistance for the pot equal to 1/4 the value of the pot. This is because the Arduino reads pots at 1024 potential values but the digital pot can only accept 256 values.

Closing Remarks

Now we have started some actual bending of the circuit. Re-purposed the Sustain knob (and tone if you want), added control for the depth of the tremolo “swell,” and made a bypass for keeping essentially the stock feel of the pedal. Next time I will button it all back up and polish a couple of minor rough edges and have a sound/function demo.

Leave a Reply

Your email address will not be published. Required fields are marked *