Skip to content

Instantly share code, notes, and snippets.

@heuermh
Created November 8, 2012 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heuermh/4041594 to your computer and use it in GitHub Desktop.
Save heuermh/4041594 to your computer and use it in GitHub Desktop.
Teensyduino sketch for USB MIDI stomp pedal board
// stomp using usb midi
#include <Bounce.h>
// midi channel
int channel = 1;
// cc values
int cc_off = 1;
int cc_on = 65;
// map buttons to cc
int cc0 = 1;
int cc1 = 2;
int cc2 = 3;
int cc3 = 4;
int cc4 = 5;
int cc5 = 6;
Bounce button0 = Bounce(0, 10);
Bounce button1 = Bounce(1, 10);
Bounce button2 = Bounce(2, 10);
Bounce button3 = Bounce(3, 10);
Bounce button4 = Bounce(4, 10);
Bounce button5 = Bounce(5, 10);
void setup()
{
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(11, OUTPUT);
}
void loop()
{
button0.update();
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
if (button0.fallingEdge())
{
usbMIDI.sendControlChange(cc0, cc_on, channel);
}
if (button1.fallingEdge())
{
usbMIDI.sendControlChange(cc1, cc_on, channel);
}
if (button2.fallingEdge())
{
usbMIDI.sendControlChange(cc2, cc_on, channel);
}
if (button3.fallingEdge())
{
usbMIDI.sendControlChange(cc3, cc_on, channel);
}
if (button4.fallingEdge())
{
usbMIDI.sendControlChange(cc4, cc_on, channel);
}
if (button5.fallingEdge())
{
usbMIDI.sendControlChange(cc5, cc_on, channel);
}
if (button0.risingEdge())
{
usbMIDI.sendControlChange(cc0, cc_off, channel);
}
if (button1.risingEdge())
{
usbMIDI.sendControlChange(cc1, cc_off, channel);
}
if (button2.risingEdge())
{
usbMIDI.sendControlChange(cc2, cc_off, channel);
}
if (button3.risingEdge())
{
usbMIDI.sendControlChange(cc3, cc_off, channel);
}
if (button4.risingEdge())
{
usbMIDI.sendControlChange(cc4, cc_off, channel);
}
if (button5.risingEdge())
{
usbMIDI.sendControlChange(cc5, cc_off, channel);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment