Sunday, July 12, 2009

void setup() {
Serial.begin(31250);
//Serial.begin(9600);
}

void loop() {
int in = analogRead(0);
//Serial.println((long)in,DEC);
midi_volume(1, in / 8);
delay(100);
}

void midi_volume(byte channel, byte vol) {
Serial.print(0xB0 | (channel & 0xf), BYTE); // control change command
Serial.print(0x01, BYTE); // volume command
Serial.print(vol & 0x7f, BYTE); // volume 0-127
}