Thursday, May 16, 2013

Infrared Distance Sensor As MIDI Controller

This is a simple example of using an infrared distance sensor as a MIDI controller. The hardware setup is simple - analog out to analog input on the Teensy, ground to ground and 5V to 5V.

The code is as follows:

byte current;
byte previous;

void setup() {
 
}

void loop() {
  current = analogRead(0) / 8;
  if(current != previous) {
    previous = current;
    sendControlChange(1, current, 1);
    delay(5);
  }
}







0 comments: