I'm trying to read midi messages from a keyboard but I can't receive my messages properly.
I feel like I receive the first octet of each message properly but not always the folowing ones.
reading midi clock messages : it works. as far as I can tell I don't seems to lose messages. I do blinking a led on the tempo and it doesn't seems to be out of sync. tested up and down from 32 bpm to 280 bpm
reading notes on/off from the keyboard (so mixed with midi clock): works partially, i can read some messages (1 out of 20 or something like that), other gives
reading notes on/off sent manually from a computer: same result
The MIDI library most definitely works.
You are using the right circuit so I would suggest that maybe there is a problem in your phsical circuit. Can you check using an LED to see if anything is actually coming out of the opto isolator?
@chubinou I am using almost the same circuit and I have a similar problem. I get probably 99 out of 100 messages correctly, then wrong controllers or stuck notes, etc. I am using a cheapo atmega328 from chinese ebay. I wonder, are you using a genuine arduino with a known-good IC? I think sometimes the cheap ebay parts are seconds and I'm thinking that may be my problem. I'm banging my head on this.
@cougar_shuttle I'm using an official arduino. Though it might be an old model: REV2 bought in 2011
@sparx266 signal is actually comming out of the optoisolator since I can receive the midi clocks messages (1 octet) properly and some notes on/off. This is not a problem on the emmission side since I can receive every notes properly if I connect the keyboard the a computer or from the computer to the keyboard
apparently this could be a problem with my keyboard
I try recording the signal from the optocoupler with my sound card (poor man's oscilloscope) but even recoded at 96K it's difficultly readable.
note on above image, the message up must be a note on, the message below a note off (a note on with 0 as a velocity). the "second part " of the message below is probably a midi clock (0xF8). the first byte of the message seems to have disappear °_°
What is strange is that if I use my PC to record my keyboard using my midi interface, I can get every notes correctly
I manage to have I made more tests PC -[midi]-> arduino and managed to get it working properly. I can receive every notes on/off from the PC. I also did the test with adding a midi clock on the PC.