4
This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
5
If this circuit is connected to a MIDI synth, it will play
6
the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.
10
* digital in 1 connected to MIDI jack pin 5
11
* MIDI jack pin 2 connected to ground
12
* MIDI jack pin 4 connected to +5V through 220-ohm resistor
13
Attach a MIDI cable to the jack, then to a MIDI synth, and play music.
19
http://www.arduino.cc/en/Tutorial/MIDI
24
// Set MIDI baud rate:
29
// play notes from F#-0 (0x1E) to F#-5 (0x5A):
30
for (intnote = 0x1E; note < 0x5A; note ++) {
31
//Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
32
noteOn(0x90, note, 0x45);
34
//Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
35
noteOn(0x90, note, 0x00);
40
// plays a MIDI note. Doesn't check to see that
41
// cmd is greater than 127, or that data values are less than 127:
42
void noteOn(int cmd, int pitch, int velocity) {
43
Serial.print(cmd, BYTE);
44
Serial.print(pitch, BYTE);
45
Serial.print(velocity, BYTE);