Create A Custom Guitar Pedal With Arduino Uno

13 May 2023 Balmiki Mandal 0 µC - µP

How to Make an Arduino UNO Guitar Pedal

Making a guitar pedal from an Arduino UNO controller can be a great way to get started with digital audio. With an Arduino UNO and some basic hardware, you can easily create your own custom guitar pedal for any application. Here is how to make your very own Arduino UNO guitar pedal. Step 1: Gather the Materials You will need:

  • Arduino UNO
  • Breadboard
  • Potentiometers (2)
  • Mono Line In Jack
  • 1/4 inch mono audio jack
  • 10K ohm resistor
  • 9V Battery

Step 2: Assemble the Breadboard Start by connecting the two potentiometers to the breadboard. Connect one of the outer pins on each potentiometer to the ground rail of the breadboard, and the other outer pin to the power rail. Step 3: Connect the Monoline In Jack Connect the monoline in jack to the breadboard. The left pin of the jack should be connected to the ground rail and the right pin should be connected to the power rail. Step 4: Connect the Potentiometers and the Audio Jack Connect the center pins of both potentiometers to the left and right inputs of the 1/4 inch mono audio jack. Step 5: Connect the Arduino UNO Connect the Arduino UNO to the breadboard in analogue input mode. Use three wires with one wire connecting the ground from the Arduino UNO to the ground rail on the breadboard. The other two wires should connect the analogue pins A0 and A1 from the Arduino UNO to the center pins of the potentiometers. Step 6: Connect the Resistor Connect the 10K ohm resistor from the power rail of the breadboard to the power pin of the audio jack. Step 7: Connect the 9V Battery Connect the 9V battery to the breadboard. The positive terminal of the battery should be connected to the power rail and the negative terminal should be connected to the ground rail. Step 8: Write the Arduino Code Using the Arduino IDE, write a program that reads the values of the potentiometers, applies a distortion effect, and outputs it to the audio jack. Step 9: Test the Effect Plug your guitar into the pedal and test the effect. Adjust the values of the potentiometer to vary the amount of distortion. Congratulations — you’ve just built your very own Arduino UNO guitar pedal!

Here is an example code for making an Arduino UNO guitar pedal using the Mozzi library:

#include <MozziGuts.h>
#include <Oscil.h>
#include <ADSR.h>

const int BUTTON_PIN = 2;
const int LED_PIN = 13;

Oscil<SAW_RES, AUDIO_RATE> oscil;
ADSR envelope;
int volume;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);
  startMozzi(AUDIO_RATE);
}

void updateControl() {
  if (digitalRead(BUTTON_PIN) == LOW) {
    digitalWrite(LED_PIN, HIGH);
    envelope.trigger(0.1, 0.5, 0.5, 0.5);
  } else {
    digitalWrite(LED_PIN, LOW);
    envelope.release(0.5);
  }
  volume = envelope.next() * 4096;
}

int updateAudio() {
  return oscil.next() * volume;
}

In this example, the Mozzi library is used to generate the audio output. The BUTTON_PIN and LED_PIN are defined as the input and output pins of the pedal.

In the setup() function, the BUTTON_PIN and LED_PIN are set as the input and output pins, respectively. The startMozzi(AUDIO_RATE) function is called to start the Mozzi audio engine with the specified sample rate.

The updateControl() function is called periodically to update the envelope of the audio signal based on the state of the button. If the button is pressed, the LED is turned on, and the envelope is triggered with a short attack time and medium decay, sustain, and release times. If the button is released, the LED is turned off, and the envelope is released with a medium release time.

The updateAudio() function is called periodically to generate the audio output. The oscillator is used to generate a sawtooth wave, which is multiplied by the current volume level based on the envelope output. The volume level is scaled to the range of 0 to 4096, which is the range of the Mozzi audio output.

Note that the Mozzi library can be used to generate other types of waveforms and to apply various effects to the audio signal. The syntax for using these features is beyond the scope of this example.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.