berlin
Offline
Sr. Member
Karma: 0
Posts: 293
|
 |
« Reply #15 on: June 08, 2008, 05:14:47 am » |
ccgibson, i know about the pain to debug this. Some of the steps I've tried: 1) I've verified my input pin works using a simple potentiometer. I can get Serial.Available to read an input byte with that set-up 2) I've tried both midi plug wiring options as described in this thread. 3) I've tried the circuit with and without the diode.
if you are already getting some serial data, i'd suggest checking just for a "144" (note-on message). Every keystroke should cause at least one. if (Serial.available() > 0) { blink(); //once to signal at least something arrived
// read the incoming byte: incomingByte = Serial.read();
// wait for as status-byte, channel 1, note on if (incomingByte== 144){ // note on message starting starting // yeaha, we're getting something blink(); blink(): blink(); } }
if you're not receiving any data, you most likely have a problem with the opto setup. are you using the 4n28? can you verify that the optocpupler [still] works? i'm not sure about your 2-watt resitors, but if they're that big, i could imagine them adding some noise. still i think you should get correct data in one of let's say a 100 key strokes. remember that you need to set your keyboard (or whatever midi device you'Re using) to use midi channel 1 to use it with this code here. good luck, kuk
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #16 on: June 08, 2008, 04:30:35 pm » |
thanks kuk.
1) I did make sure midi communication was occuring over channel 1. 2) I'm not getting any serial data, so i'm not filtering at all right now.
I have a bunch of 4n28s but I'm not sure the best way to validate it is still working. Any quick hints?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #17 on: June 11, 2008, 02:55:12 am » |
nevermind! Got it working, finally!
thanks for all the help.
|
|
|
|
|
Logged
|
|
|
|
|
berlin
Offline
Sr. Member
Karma: 0
Posts: 293
|
 |
« Reply #18 on: June 11, 2008, 03:24:47 am » |
cool. what gave the trouble?
|
|
|
|
|
Logged
|
|
|
|
|
0
Online
Newbie
Karma: 0
Posts: 29
Arduino rocks
|
 |
« Reply #19 on: July 14, 2008, 12:51:50 pm » |
Does anybody happen to have a copy of the schematic for this? Unless it's just something weird on my end, the image from the original post is missing. Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 1
Arduino rocks
|
 |
« Reply #20 on: August 28, 2008, 04:59:22 pm » |
Is there any chance to get MIDI data from the USB directly in osx? thanks!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #21 on: January 08, 2009, 09:01:24 am » |
thank you very much for this! this works perfectly...
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #22 on: January 08, 2009, 09:03:49 am » |
if you want to make a MIDI-in shield for the arduino based on this schematic you can get layout, parts list etc. there: http://www.instructables.com/id/Arduino_MIDI_in_shield/
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 20
Prototype Limited Edition owner! lol
|
 |
« Reply #23 on: February 20, 2009, 10:24:36 am » |
Thanks Carkat, thats the first MidiIn schematic that worked for me! Using a 4N27. 
|
|
|
|
« Last Edit: February 20, 2009, 10:24:48 am by Intosia »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« Reply #24 on: February 22, 2009, 12:03:31 pm » |
Firstly, I'm trying to put together my own MIDI instrument, and found this code indispensable -- thanks Kuk! But, as a programming n00b, I don't really understand the why 'action' is necessary -- would anyone mind explaining that to me, please.  Also, just to check -- in the initial code, the blink subroutine (was that the correct term?) isn't used is it? Again, thanks for the very helpful code.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 171
"So...What does this thing do?"
|
 |
« Reply #25 on: March 16, 2009, 07:45:24 pm » |
I got a Korg MicroKorg for xmas a while back only to find that it didn't have a sequencer built in  . So, I've decided I'm going to make an Arduino do some MIDI IN/OUT, and act as a cool sequencer accessory. I'm using a small backlit serial LCD, some multi-color LED bar graph displays, a few HC595's, a large pot, and (possibly) 2 Arduinos. I figure I'll have two Arduinos to make the setup easier to program (master-slave config). I hope to get it to the point where the Arduino(s) will get all key, knob, and other MIDI status messages from the microKorg, and save that info in each step along with the program number (for each unique program sound). It'll then be able to play it back in sequence at a variable tempo. I'll update here if you'd all like! 
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
Sr. Member
Karma: 0
Posts: 262
|
 |
« Reply #26 on: March 22, 2009, 06:30:33 am » |
Hello! I'm on a MIDI project and this topic was very useful, thanks! I'm playing around with this code and don't get it working. All I want is to have the led on when a note is on and the led off when the note is off (no polyphony). Here is the code: //variables setup byte incomingByte;
int statusLed = 13; // select the pin for the LED
//setup: declaring iputs and outputs and begin serial void setup() { pinMode(statusLed,OUTPUT); // declare the LED's pin as output Serial.begin(31250); //start serial with midi baudrate 31250 or 38400 for debugging digitalWrite(statusLed,LOW); }
void loop () {
if (Serial.available() > 0) {
incomingByte = Serial.read(); // wait for as status-byte, channel 1, note on or off
if (incomingByte== 144){ // note on digitalWrite(statusLed, HIGH); } else if (incomingByte== 128){ // note off digitalWrite(statusLed, LOW); } }
}
The problem is that my led goes on, but never off! Any idea? Thanks 
|
|
|
|
|
Logged
|
|
|
|
|
berlin
Offline
Sr. Member
Karma: 0
Posts: 293
|
 |
« Reply #27 on: March 22, 2009, 06:53:06 am » |
hi tep, probably your keyboard sends "Note ON w ZERO velocity" instead of "NOTE off". the ones i tested do this.
best, kuk
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
Sr. Member
Karma: 0
Posts: 262
|
 |
« Reply #28 on: March 22, 2009, 07:46:08 am » |
Thank you kuk, you're probably right. I tested this void loop () { if (Serial.available() > 0) {
incomingByte = Serial.read(); // wait for as status-byte, channel 1, note on or off if (incomingByte== 144){ // note on digitalWrite(statusLed, HIGH); note=incomingByte; velocity=incomingByte; if (velocity==0){ // note off digitalWrite(statusLed, LOW); } } } }
and still no result. But it's perhaps not the best way to get the velocity ?  tep
|
|
|
|
|
Logged
|
|
|
|
|
berlin
Offline
Sr. Member
Karma: 0
Posts: 293
|
 |
« Reply #29 on: March 25, 2009, 03:39:11 am » |
first, your code fragment does not update the value of "incomingByte"... you have to re-read form the serial buffer, like in the first line of your code, to get the next received byte.
plus: ok, i'm really not into midi right now. but if i remember correctly there was something else to mention:
AFTERTOUCH messages are like NOTE ON (OFF) messages without explictly mentioning which note to play or stop. in that case you have to ON/OFF the _last_ note which was explicitly sent. the code i posted at the beginning of this thread does not reflect this, because my (midiman oxygen) keyboard did not seem to use aftertouch.
keep me/us updated please and good luck.
//kuk
|
|
|
|
|
Logged
|
|
|
|
|
|