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. (https://www.youtube.com/watch?v=HWQhY1StF7o)
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)
include
MIDI_CREATE_DEFAULT_INSTANCE();
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 }