My goal is to blink an LED anytime I receive a message from my tmc-6 (drum trigger midi converter). Basically, anytime I hit a drum trigger I want to blink the LED. I'm not sure if it's my code or my hardware that is malfunctioning. I am using a circuit designed around the TLP2630 opto-isolator. I've also used SoftwareSerial and have failed. Here's my code using MIDI.h, thanks in advance! :):
OK so now you need to include a link to where you got this library from so people can reproduce it.
I rarely use libraries myself because when they go wrong you have to do more work that you would if you just did it yourself in the first place.
Here is how to read MIDI input and light an LED or fire a solenoid without any libraries. http://www.thebox.myzen.co.uk/Hardware/Glockenspiel.html
Here's the link: Arduino Playground - MIDILibrary
I tried something similar to that using SoftwareSerial before I ran across MIDI.h. I'll look back into it, using hardware serial, if I can't get this library to work. Thanks for your reply.
What version of the arduino IDE are you using. I can't get this library to work on version 1.1.
Did you change the name from the down loaded zip file?
Are you having trouble compiling this or do you just get nothing when you run it?
I'm using 1.0.1.
I haven't changed the name, I just unzipped into my library.
It compiles fine, I just don't get a response when I run it.
I finally got it to output to the debug screen using SoftwareSerial:
#include <SoftwareSerial.h>
/*****************************************
* Initialize Pins & variables *
*****************************************/
#define ledPin 14
byte incomingByte;
SoftwareSerial midi(2, 3);
/*****************************************
* Setup *
*****************************************/
void setup()
{
pinMode(ledPin, OUTPUT);
midi.begin(31250);
Serial.begin(9600);
}
/*****************************************
* Main Loop *
*****************************************/
void loop()
{
{
// send data only when you receive data:
if (midi.available() > 0) {
// read the incoming byte:
incomingByte = midi.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
}
Now that I can see the values I can work with it a lot easier. I could have sworn I wrote similar code yesterday and it didn't work!?! Anyhow, I didn't want to use hardware serial because I keep having to unplug the serial wire each time I uploaded code. I think I will stay on this path for now. Thanks for all your help!