Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Circuit
All MIDI connectors are female, by definition of the MIDI spec. Here's how to wire the connector to
the Arduino:
- Arduino digital pin 1 connected to MIDI jack pin 5
- MIDI jack pin 2 connected to ground
- MIDI jack pin 4 connected to +5V through 220-ohm resistor
(http://arduino.cc/en/uploads/Tutorial/MIDI_bb.png)
image developed using Fritzing (http://www.fritzing.org). For more circuit examples, see the Fritzing project page
(http://fritzing.org/projects/)
Schematic
click the image to enlarge
(http://arduino.cc/en/uploads/Tutorial/MIDI_schem.png)
Code
/*
MIDInoteplayer
Thissketchshowshowtousetheserialtransmitpin(pin1)tosendMIDInotedata.
IfthiscircuitisconnectedtoaMIDIsynth,itwillplay
thenotesF#0(0x1E)toF#5(0x5A)insequence.
Thecircuit:
*digitalin1connectedtoMIDIjackpin5
*MIDIjackpin2connectedtoground
*MIDIjackpin4connectedto+5Vthrough220ohmresistor
AttachaMIDIcabletothejack,thentoaMIDIsynth,andplaymusic.
created13Jun2006
modified13Aug2012
byTomIgoe
Thisexamplecodeisinthepublicdomain.
http://www.arduino.cc/en/Tutorial/Midi
*/
voidsetup(){
//SetMIDIbaudrate:
Serial.begin(31250);
}
voidloop(){
//playnotesfromF#0(0x1E)toF#5(0x5A):
for(intnote=0x1E;note<0x5A;note++){
//Noteonchannel1(0x90),somenotevalue(note),middlevelocity(0x45):
noteOn(0x90,note,0x45);
delay(100);
//Noteonchannel1(0x90),somenotevalue(note),silentvelocity(0x00):
noteOn(0x90,note,0x00);
delay(100);
}
}
//playsaMIDInote.Doesn'tchecktoseethat
//cmdisgreaterthan127,orthatdatavaluesarelessthan127:
voidnoteOn(intcmd,intpitch,intvelocity){
Serial.write(cmd);
Serial.write(pitch);
Serial.write(velocity);
}
[GetCode](http://arduino.cc/en/Tutorial/Midi?action=sourceblock&num=1)
See Also:
- serial.begin() (http://arduino.cc/en/Serial/Begin)
- for() loop (http://arduino.cc/en/Reference/For)
- Serial Call Response (http://arduino.cc/en/Tutorial/SerialCallResponse) - send multiple variables using a call
and response (handshaking) method.
- For Loop (http://arduino.cc/en/Tutorial/ForLoop): - controlling multiple LEDs with a for loop.
- ASCII Table (http://arduino.cc/en/Tutorial/ASCIITable): - generates a table of characters and their ASCII,
hexadecimal, octal, and binary equivalents.
Share
NEWSLETTER
SUBSCRIBE
Enter your email to sign
up
(https://twitter.com/arduino)
(https://plus.google.com/+Arduino)
(http://youtube.com/arduinoteam)
(http://www.facebook.com/official.arduino)
(http://www.flickr.com/photos/arduino_cc)