talofer99 icon

midi example

talofer99 | PRO | 10/14/19 05:08:39 AM UTC | 0 ⭐ | 388 👁️ | Never ⏰ | []
text |

640 B

|

None

|

0 👍

/

0 👎

int sensorPin = A0;
int sensorValue = 0;
 int channel = 0 // this is the midi channel 
 void setup() {
Serial.begin(9600);
}
 void loop() {
midiNoteOn(0,127); // turn note ZERO at pitch 127 (max)
delay(1000);
midiNoteOff(0); // turn off note ZERO
delay(1000);
}
  void midiNoteOn(byte note, byte midiVelocity)
{
Serial.write(144 + channel); //NOTE_ON_CMD (its base + channel # starting at ZERO!)
Serial.write(note);
Serial.write(midiVelocity);
}
void midiNoteOff(byte note, byte midiVelocity)
{
Serial.write(128 + channel); // NOTE_OFF_CMD (its base + channel # starting at ZERO!)
Serial.write(note);
Serial.write(midiVelocity);
}

Comments