musiquemeuble
Active member
hello guys !
I'm new here and I really enjoy Teensy.
I'm building a midi controller with 2 CC messages for Ableton with Teensy 3.5. My project is to have 1 potentiometer + 1 proximity sensor. I have no problem with the potentiometer, but I don't know how to include the proximity sensor to the code. I've found CapacitiveSensor library which is great, but I can only find for Serial, and not for midi CC. I have several resistor in my possession (1Mohm / 10Mohm / 22 Mohm)
Can you help me with that?
Here is the actual code
I'm new here and I really enjoy Teensy.
I'm building a midi controller with 2 CC messages for Ableton with Teensy 3.5. My project is to have 1 potentiometer + 1 proximity sensor. I have no problem with the potentiometer, but I don't know how to include the proximity sensor to the code. I've found CapacitiveSensor library which is great, but I can only find for Serial, and not for midi CC. I have several resistor in my possession (1Mohm / 10Mohm / 22 Mohm)
Can you help me with that?
Here is the actual code
Code:
/* USB MIDI AnalogControlChange Example
You must select MIDI from the "Tools > USB Type" menu
http://www.pjrc.com/teensy/td_midi.html
This example code is in the public domain.
*/
#include <Bounce.h>
// the MIDI channel number to send messages
const int channel = 1;
// the MIDI continuous controller for each analog input
const int controllerA0 = 10; // 10 = pan position
void setup()
{
}
// store previously sent values, to detect changes
int previousA0 = -1;
elapsedMillis msec = 0;
void loop() {
// only check the analog inputs 50 times per second,
// to prevent a flood of MIDI messages
if (msec >= 20) {
msec = 0;
int n0 = analogRead(A0) / 8;
// only transmit MIDI messages if analog input changed
if (n0 != previousA0) {
usbMIDI.sendControlChange(controllerA0, n0, channel);
previousA0 = n0;
}
}
// MIDI Controllers should discard incoming MIDI messages.
// http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash
while (usbMIDI.read()) {
// ignore incoming messages
}
}