Sharp Infrared Proximity Sensor to send MIDI messages

Hello I'm trying to make a midi controller with IR short distance proximity sensor to control sound. (in ableton or traktor).

This video shows exactly what I want to do. (

I'm using hairlessMIDI to convert arduino serials to MIDI. My controller has many push buttons & potentiometers (linear & rotatry) and I got them to work! But I can't figure out how to convert IR sensor readings into MIDI. I thought It would be similar to linear potentiometer..but I'm not getting any MIDI signals from it. I'm very new to arduino and I need help from you guys!

Here is my code. (I'm just trying to figure out IR sensor to MIDI alone for now)



const int analogInPin = A0; // Analog input pin that the ir-sensor is attached to

int sensorValue = 0; // value read from the sensor int outputValue = 0; // value output to the midi int outputValue_old = 0;

const byte channel = 0;

void setup() { Serial.begin(115200); } void loop() {

// read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 48, 96); // change the analog out value:

if (outputValue != outputValue_old) { MIDI.sendNoteOff(outputValue_old,0,1); // Stop the old note MIDI.sendNoteOn(outputValue,127,1); // Send a new Note (pitch , velocity 127, on channel 1) outputValue_old = outputValue; } delay(80); // for staiblity }

Screen shot 2015-04-17 at 오전 1.55.51.png|607x383

Screen shot 2015-04-17 at 오전 2.00.41.png|720x312

The code look fine apart from:- YOU HAVE NOT USED CODE TAGS!!! :stuck_out_tongue_closed_eyes:

What values do you see from the sensor if you just write code to print it out?

Have you used a MIDI scope to look at what Hairless is receiving?