Working Breadboard Prototype

When I received the buttons I ordered for the midi controller, they were much too flimsy for me to be stepping on. They are better suited for finger presses. So I went back and ordered the foot switches, and got some heartier potentiometers while I was ordering so I have a selection of a few.

While I was waiting for the new hardware to arrive, I put together a working breadboard prototype. It only has 4 buttons and one pot, but it would be easy enough to scale up.

Mini-Midi Controller

Hardware

  • 1 Teensy 3.1 with USB Connection
  • 1 Breadboard
  • 4 Tactile Push Buttons
  • 4 LEDs
  • 4 Resistors (220 ohm)
  • 1 Potentiometer (10k ohm)

Breadboard Setup

The parts are assembled to the breadboard as per the diagram below. Note that I’ve moved my LEDs in the picture above so that they are right next to the button they are associated with, however they are not connected to the button directly. The diagram shows the buttons and LEDs separated, and only one of each connected to four digital pins(there should be four, one for each digital pin).

There are three mini-circuits:

  1. The each of the four LEDs are connected to an output pin (digital pin 2 though 5) on the positive side and a 220 ohm resistor on the negative side to keep the LED from burning out. Each resistor is connected then to ground. The lights will turn on when the signal is set to HIGH.
  2. The four pushbuttons are connected one side to an input pin (digital pin 6 though 9) and the other side to ground. When the inputs are in pull-up (resister) mode, they will read as HIGH until the button is pressed, dropping the signal to LOW.
  3. The single pot is connected to 5V on one side, and ground on the other. The center is connected to analog pin 0.

Mini Midi Controller

Program

Make sure you set the board to your Teensy 3.1 board in the Tools menu. You also will want to change the Tools > USB Type to MIDI instead of Serial.

I’ve left out most of the commenting for code that is similar/identical to that in our simple midi controllers thus far. You can reference back to their code here: Single Button Controller / Single Potentiometer Controller. However, lines 56-71 are new. More about that below.

Enter the following sketch:

If when you verify the sketch, you get the message “fatal error: Bounce.h: No such file or directory”, then you are missing the Bounce library in your project. Check out this post to make sure you have installed the library to your Arduino Library list.

What I haven’t covered in my previous two midi controller build posts is adding an LED that shows the state of the event the buttons are controlling. Simply put, when I first press a button, it should turn on an effect, while also lighting up an LED so that you can visibly see that it was turned on. The next time you press the button, the effect should be turned off, as well as the LED.

We’ve talked about using the debouncer objects to trigger on a downpress, so I’ll focus on the two lines of code that fall inside the if statements (lines 57 and 58 above).

Digital pins can only be in two states – HIGH or LOW. These states are equivalent to True and False, or 1 and 0. So if add HIGH to an integer, like 53, the answer will be 54.

The first line reads like this: “Assign to digital pin LEDPinA the value: not the current value of LEDPinA”. Essentially, it is setting the pin to the opposite of what that pin is currently set at. If the pin is set to LOW (and this is how it starts when the program initializes), then this will change it’s value to HIGH, turning the light on. If it is HIGH, the pin will be set to LOW. It is essentially a one line on/off toggle.

The second line always sends a control change midi message (in this case to control #20) and sets the value to 127 multiplied the value of the LED pin. The LED pin could be HIGH or LOW. If the light just turned on, its HIGH value is read as a “1” and the midi message tells the control to be set to 127 (maximum value) which equates to the “on” state for the control inside my music program. If the light just turned off, the midi value will be 127 multiplied by 0, turning off the control inside the connected device.

2 Responses to “Working Breadboard Prototype

  • Thanks so much for posting your teensy project, really! I’ve been research on and off for months, about arduino and midi. I’ve never programed either, so trying to learn from the ground up. I would like to make my own midi Pedalboard. I have lots of ideas, and a Google sketchup, but that’s all so far. Next is a teensy, a breadboard, and components(Haven’t found a midi breadboard kit). All I can say is Bravo, and thank you! Your project is inspiring

    • Thanks Mike! I hope you have found some helpful content here. I’ve been meaning to post the final product that I put together, although I haven’t yet designed the expression pedal. It’s only a 4×2 set of stomp buttons.

      Good luck on your project!

      – Trevor

Leave a Message!

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