Saturday, September 03, 2011

MIDI with Teensy: Light Controlled Pitch Bends




Hardware
:



Software:
int current_analog;

int previous_analog;

int current_button;
int previous_button;

void setup() {
pinMode(0, INPUT);
digitalWrite(0, HIGH);
pinMode(11, OUTPUT);
}

void loop() {
current_analog = analogRead(0);
if(current_analog != previous_analog) {
usbMIDI.sendPitchBend(current_analog << 4, 1);
previous_analog = current_analog;
delay(1);
}


current_button = digitalRead(0);
if(current_button != previous_button) {
usbMIDI.sendNoteOn(60, 127 * (! current_button), 1);
delay(5);
previous_button = current_button;
}
}

0 comments: