Last active
April 23, 2016 18:26
-
-
Save prasertsakd/c4cd8c039913c0337b1fa0899962bad2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//midi test | |
void setup() { | |
// Initialise Serial connection | |
Serial.begin(115200); | |
//midi | |
//nodemcu use pin D4 for TX | |
Serial1.begin(31250); | |
} | |
int note[] = { 0x3C,0x3E,0x40,0x41,0x43,0x45,0x47, | |
0x48,0x4A,0x4C,0x4D,0x4F,0x51,0x53,0x55}; | |
void loop() { | |
for (int i=0;i<8;i++) { | |
Serial.println(i,DEC); | |
midiSend(0x90, note[i],0x60); | |
delay(100); | |
midiSend(0x80, note[i],0x00); | |
delay(100); | |
} | |
Serial.println(); | |
} | |
void midiSend(int cmd, int pitch, int velocity) { | |
// int note2[] = { 0x23,0x26,0x34,0x32,0x2F,0x2B,0x34}; | |
// int note[] = { 0x3C,0x3E,0x40,0x41,0x43,0x45,0x47, | |
// 0x48,0x4A,0x4C,0x4D,0x4F,0x51,0x53,0x55}; | |
Serial1.write(cmd); | |
Serial1.write(pitch); | |
Serial1.write(velocity); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment