works: MIDI-IN: code + schematics

@sciguy: :slight_smile:

@AndreasViruly: Good, now I guess it'll be very quick, if you only want to light on LED on notes! :wink:

Haha, no that was just the first step. I want to make 36 different LED's corresponding to 3 octaves on the piano. Everytime a note is played on the master keyboard, these LED's have to light up, and go out the moment the key is released. I already saw my keyboard works with the "note on" with 0 velocity, when switching off a note..
I only have 13 pins on my Arduino so I have to start working with multi/charlieplexing.
Programming is just completely new for me so it'll take quite a while I think :wink:
But thanks anyhow!
Andreas

(pins 2-13 = 12 pins + analog pins = 6 pins. Total 18 pins ! ;))
Ok, those methods are good, but not very adapted if you plan to do other time-consuming things. I can recommend you shift registers. I got mine 5 for 1 us$ from Thailand on eBay. It's of course more assembly, but if you go this way I can give you a function to light LEDs a simple way.
Anoter thing : have a look at registers that handle PWM, you could handle the velocity!

On my MIDI controller with the MIDI IN issue I consolidated some solder and now found out that if I connect the RX pin to the RX pin of an empty Arduino Diecimila my onboard standalone Arduino receives the signal.

Do you have an idea of how to solve this?
[edit]Hm no, doesn't work anymore this way.[/edit]

Something strange: My MIDI IN circuit always work when I connect it to an Arduino. When it is a standalone Atmega, it doesn't work anymore. :frowning:

Look at this schematic :

He is using a 8-pin optocoupler, but he adds a 1.8k resistor to ground. What you think about it?
(My electronic knownledge is very small...)

Haven't seen it mentioned here, but I combined this sketch with teh serial to midi converter and it worked just taking the midi in through USB. Thanks for the sketch! I finally got my ableton clips triggering and flasing a LED at me when launched. Nice!

Hey, thanks for all your information, I have an arduino receiving midi from a controller or from the computer..!

Now i have another problem!! (when will i finish!?jejeje) i bought a 9V AC/DC for go everywhere with my arduino and my midi controller. But without the USB power it doesn't works!! What happens?!

I have the circuit done and working, but here is the problem:

With this code, happens two diferent thinks with power via USB or 9V black power jack.

without usb power, never is available, the serie...

int statusLed=13;  //one
int statusLed2=12;  //ten
int statusLed3=11;  //hundred
byte incomingByte;

void setup() {
  pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  pinMode(statusLed2,OUTPUT);   // declare the LED's pin as output
  pinMode(statusLed3,OUTPUT);   // declare the LED's pin as output

  Serial.begin(31250); //9600 for USB i 31250 for MIDI i 38400 for debugging
}

void loop () {
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
    blink(HIGH,statusLed);
    delay(temps);
    blink(LOW,statusLed);
    delay(20);
  }
}

void blink(byte valor, int nled){
  digitalWrite(nled, valor);
}

anyone can help me?

thanks a lot!

Hi!
Just to let you know where my problem is:

It is the resistance between RX and 5V.
It should be measured as about 1k to connect either MIDI or USB.
So I can't for now have a standalone solution where it is possible to connect the FTDI from time to time because the resistance is then too low or too high without the FTDI.

I can put a switch to enable a parallel resistor to the 3,3k one : enabled would be MIDI, disabled would be FTDI.
Or perhaps a transistor?
Or a FTDI in my enclosure... I made eveything to not have the need of it, but... And it would allow me also to have MIDI over Serial/USB connectivity.

So, for now I don't really know. I could try a transistor, but would it allow 9600 or 11250bps? I'm not sure with a 2N2222? (Their frequency is 250MHz or 300MHz)

Another thing: check out Ruin&Wesen library, could help some! :wink: http://ruinwesen.com/blog?id=582

hi, i'm searching a circuit of a MIDI THRU for put in this MIDI IN circuit, anyone can help me?

thanks!

I believe it's the same you can find eveywhere, not very minimalist...
Look at this one :

thanks for the fast answer!

but, what's p23? is it the out of octocoupler?
I understand the M151250 is the octocoupler isn't true?

the 3k9 resistor is the 3k3 and the 100k resistor isn't painted.

Any example for a IC17 and IC18?

thanks

Sorry, this seems not the best schematic since it comes from a book and the guy didn't scan everything...
For what I can answer:

  • The M151250 is the 6-pin optocoupler, it seems very similar to ours.
  • The 3k9 resistor depends on the circuit. As I mentioned previously, with a standard Arduino it is 3k3 and a standalone Atmega chip without FTDI it is 1k.
  • Don't worry about the 100k! It works without and often better! (see other pages of the topic)

IC17 and IC18... hum, we'll have to find another schematic I guess!
[edit]http://whitefiles.org/b1_s/1_free_guides/fg1mt/pgs/h10d.htm ?[/edit]

this schematic is enouth?

http://www.instructables.com/files/deriv/FXY/7LDR/F6S8S2BV/FXY7LDRF6S8S2BV.MEDIUM.jpg

thanks!

The best would be to try it out! :wink:

If you could also post a link to this instructable?

it is a part of a Pod Guitar project:

http://www.instructables.com/id/SJZFF32F6S8S2BY/

i'll try this circuit, i'll post if it's ok if you want

Seem to have got the MIDI in code working. I'm hoping to send DMX outputs controlled by MIDI inputs. For this will I need:

2 arduinos?

A Processing - Arduino link?

I think I've spent too much time looking at a computer screen today - forgive any vastly stupid ideas :wink:

I have finally gotten the midi in schematic to work with a casio keyboard using the following code.

char incomingByte;
byte note;
byte velocity;


int statusLed = 13;   // select the pin for the LED

int action=2; //0 =note off ; 1=note on ; 2= nada


//setup: declaring iputs and outputs and begin serial
void setup() {
  //start serial with midi baudrate 31250 or 38400 for debugging
  Serial.begin(31250);        
  digitalWrite(statusLed,HIGH);  
}

//loop: wait for serial data, and interpret the message
void loop () {
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
Serial.print(incomingByte,HEX);
}

}

However, by checking the signals through USB in S2MIDI, it doesn't seem that the computer is receiving actual MIDI commands. Hexadecimal values appear when I press and release keys, but they don't represent actual midi values. Any ideas? (Here is S2MIDI's output for playing c through c (one octave))

2D 33 33 2D 33 37
2D 33 33 2D 34 39
2D 36 39 2D 37 33
2D 36 39 2D 31 2D 31
2D 33 35
2D 35 2D 33 2D 31
2D 33 33
2D 33 37 32 39
2D 33 35
2D 33 2D 31
31 32 33 2D 33 35
2D 31 37
2D 35 2D 33 33
2D 35 2D 31 2D 31
2D 32 31 2D 31
2D 35 2D 33 2D 31

How is your setup ? Can you draw a quick schematic ?
(0x2D=45 and that's what you get if you send 144 (note on) at 9600bps and receive at 31250.)

*The question mark device represents the midi connector from the keyboard. Also, the optocoupler is a 4N28, not what it says in the photo.

**SO does that mean that I should be receiving in 9600 to get MIDI data correctly??? That doesn't make sense...