Complete newbie interested with Teensy for MIDI foot controller

Status
Not open for further replies.

j2sip

New member
Hi,

I have already tried the search function but the results got me more confused. But I just have to tell that Arduino is a new new thing to me. A complete Arduino Noob, that's me :D So, kindly point me to a MIDI foot control project specific for guitar that uses Teensy 2.0, and the other tech that goes with it (the hardware, programming, etc).

PS. I'm going to use this to control guitar rig.
Thank you.

Jordan
 
Last edited:
Hi j2sip, you must mention first what software or hardware guitar effect or whatever you want Teensy 2.0 to control, or mention what MIDI messages do you intend to create with your Teensy 2.0 to control your effect modules. About MIDI messages, if your effect module supports it, it will be found in its own manual.
 
Hi. Thank you for the response. As Guitar Rig has a midi learn function, I guess I would assign MIDI CC 64 and 65 for bank up/down, 66 to 71 for patch change within the bank. I've already read about basic setups and as a DIYer I think I understand some already.

Are there ready made codes that I could use with that basic requirement that I mentioned?
 
Last edited:
Hi, sorry for the very late post, I've been very busy this past few days for our school thesis project.
I wrote this code for you. Hope this works! :)
Is it really Teensy 2.0 (the short one) or Teensy++ 2.0 (the long one)?

Code:
// Hardware: Teensy 2.0, footswitch (momentary, not latching), some wires
// MIDI hardware: 220 ohm resistor, MIDI port, MIDI cable
// You don't need MIDI input hardware (anything connected to pin 7 and before that)
// because it is not implemented in this code

// Connections: connect one pin of every footswitches to pin numbers below, and other pins to ground,
// and create connections for MIDI hardware

#define pin1 0 // you can edit pin numbers here
#define pin2 1
#define pin3 2
#define pin4 3
#define pin5 4
#define pin6 5
#define pin7 6
#define pin8 9
// pins 7 and 8 are used by MIDI library for Teensy 2.0, don't use them for footswitches

#define bounceDuration 10 // increase this value if each footswitch press creates more than 1 patch/bank change

#include <Bounce.h> // include Bounce library (http://www.pjrc.com/teensy/td_libs_Bounce.html)
#include <MIDI.h> // include MIDI library (http://www.pjrc.com/teensy/td_libs_MIDI.html)

Bounce footSwitch1 = Bounce(pin1, bounceDuration); // create Bounce instances for each footswitch pin
Bounce footSwitch2 = Bounce(pin2, bounceDuration);
Bounce footSwitch3 = Bounce(pin3, bounceDuration);
Bounce footSwitch4 = Bounce(pin4, bounceDuration);
Bounce footSwitch5 = Bounce(pin5, bounceDuration);
Bounce footSwitch6 = Bounce(pin6, bounceDuration);
Bounce footSwitch7 = Bounce(pin7, bounceDuration);
Bounce footSwitch8 = Bounce(pin8, bounceDuration);

MIDI_CREATE_DEFAULT_INSTANCE(); // don't know what this is but comment it out if you are not using Teensyduino v1.37 or later

byte control; // declare some variables
byte value;
byte channel = 1; // MIDI channel is set to 1

void setup() {
  pinMode(pin1, INPUT_PULLUP); // configure footswitch pins as inputs with pullup resistors
  pinMode(pin2, INPUT_PULLUP);
  pinMode(pin3, INPUT_PULLUP);
  pinMode(pin4, INPUT_PULLUP);
  pinMode(pin5, INPUT_PULLUP);
  pinMode(pin6, INPUT_PULLUP);
  pinMode(pin7, INPUT_PULLUP);
  pinMode(pin8, INPUT_PULLUP);
  MIDI.begin(MIDI_CHANNEL_OMNI); // initialize MIDI library and serial port
  pinMode(11, OUTPUT); // configure LED pin as output for the LED to light up
  digitalWrite(11, HIGH); // turn on LED
}

void loop() {
  footSwitch1.update(); // update footswitch status (read pins)
  footSwitch2.update();
  footSwitch3.update();
  footSwitch4.update();
  footSwitch5.update();
  footSwitch6.update();
  footSwitch7.update();
  footSwitch8.update();
  
  if(footSwitch1.fallingEdge()) { // if footswitch is pressed
    control = 64; // MIDI CC 64, change this as per your needs
    value = 0; // MIDI CC value, change this as per your needs
    MIDI.sendControlChange(control, value, channel); // send MIDI data
  }
  
  if(footSwitch2.fallingEdge()) { // process repeats but for another footswitch
    control = 65;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
  
  if(footSwitch3.fallingEdge()) {
    control = 66;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
  
  if(footSwitch4.fallingEdge()) {
    control = 67;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
  
  if(footSwitch5.fallingEdge()) {
    control = 68;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
  
  if(footSwitch6.fallingEdge()) {
    control = 69;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
  
  if(footSwitch7.fallingEdge()) {
    control = 70;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
  
  if(footSwitch8.fallingEdge()) {
    control = 71;
    value = 0;
    MIDI.sendControlChange(control, value, channel);
  }
}
 
Last edited:
Wow!!! that was quick! Thank you so much. I have yet to buy the board but this, this will make good study for me! Thank you so much!

PS it's just the Teensy 2.0, according to pics in the sellers site.
 
Just noticed a small error in the code.

It looks like all of the footSwitch1 - 8 use pin1. You'll want to change them so footSwitch2 uses pin2, footSwitch3 uses pin3, etc
 
Thanks mattbott, I certainly overlooked at that one, I'm using copy+paste most of the time (and modify them afterwards) haha :).
I updated the code.

j2sip, you should check Arduino Reference Page or an offline version found at
"C:\Program Files (x86)\Arduino\reference\www.arduino.cc\en\Reference\HomePage.html",
provided you install Arduino in your PC. That's where I first learned programming.

Also, if you both have Arduino and Teensyduino, this may help you out:
BUILT-IN ARDUINO EXAMPLES
• "C:\Program Files (x86)\Arduino\examples"
ARDUINO LIBRARIES EXAMPLES
• "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" (find and open the "examples" folder inside each folders there)
• "C:\Program Files (x86)\Arduino\libraries" (find and open the "examples" folder inside each folders there)
TEENSYDUINO LIBRARIES EXAMPLES
• "C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries" (find and open the "examples" folder inside each folders there)
 
Status
Not open for further replies.
Back
Top