Teensy 2 MDI Question

Status
Not open for further replies.

marmaduke

New member
Hello

Was just trying the basic to see output using the following program -

#include <Arduino.h>
#include <MIDI.h>

/*
Basic I/O MIDI tutorial
by Franky
28/07/2009
*/

#define LED 13 // LED pin on Arduino board

void setup() {
pinMode(LED, OUTPUT);
MIDI.begin(4); // Launch MIDI with default options
// input channel is set to 4
}

void loop() {
if (MIDI.read()) {
digitalWrite(LED,HIGH); // Blink the LED
MIDI.sendNoteOn(42,127,1); // Send a Note (pitch 42, velo 127 on channel 1)
delay(1000); // Wait for a second
MIDI.sendNoteOff(42,0,1); // Stop the note
digitalWrite(LED,LOW);
}
}

I recently changed the pin back to 13 to try the program on Teensy 3.1 and added the include statements as suggested in another post but same results. Never see the led change. I am using a MAC so was unsure if I need to set something up? Would appreciate any suggestions. Thank you.

Cheers, Michael
 
Which version of the MIDI library are you using?
What circuitry are you using with this?
Could you link to the 'another post'?
 
I believe the version of MIDI.h is version 3.2. And no circuit, thought I could just sent the note to the teensy and blink the led? I am new to this so am quite sure I am doing something wrong. And apologies I will need to search for the post. Thank you for the reply.

Cheers, Michael
 
Your sketch is reading from circuitry that isn't there; so
Code:
if (MIDI.read()) {
is false, so doesn't get executed.

When you say 'send the note to the teensy' how are you sending it?
 
Are you using MIDI 3.2 downloaded from sourceforge, or the copy from PJRC.

The PJRC one has a couple extra lines of code, so MIDI will use "Serial1" instead of "Serial". Look for it near the comments in the code which explain you should set it to the port you want to use.

On Teensy, "Serial" is the USB virtual serial. If you use the unmodified copy of MIDI 3.2, MIDI.read() will look for bytes to arrive on the USB virtual serial. Obviously you want it to look for bytes arriving on the real serial port.
 
Thank you both for your help, I now have the led blinking. Am using the test program from Pd-extended and have the teensy set as input an output. I used the program from the web page Paul supplied and seems I needed the usbMidi command. And yes for now I am just going through USB. Thank you again.

Cheers, Michael
 
Status
Not open for further replies.
Back
Top