teensy_ino
Active member
Hello everybody,
I am trying to send Midi NoteOn / Off with the Teensy 3.2 depending on the voltage applied to A1 via USB.
Note On, for example, only when the voltage is above 3V, NoteOff only when the voltage is below 1V.
Basically it works - but:
NoteOn and Off messages are output as a continuous signal ...
That sounds like an old alternating current bell in the connected midi instrument ... - and because of the high midi traffic it leads to the midi
instrument "hanging up" ...
How can I achieve that Note ON / Off is only output once when the threshold values are reached?
regards
I am trying to send Midi NoteOn / Off with the Teensy 3.2 depending on the voltage applied to A1 via USB.
Note On, for example, only when the voltage is above 3V, NoteOff only when the voltage is below 1V.
Basically it works - but:
NoteOn and Off messages are output as a continuous signal ...
That sounds like an old alternating current bell in the connected midi instrument ... - and because of the high midi traffic it leads to the midi
instrument "hanging up" ...
Code:
float voltage = 0;
float voltage_Old = 0;
int midiNeu = 0 ;
int midiOLD = 0 ;
void setup() {
analogReadResolution (16); // 16 Bit = 65536 (3.31 / 65536);
Serial.begin(115200);
}
void loop() {
voltage = analogRead(A1) * (3.31 / 65536);
if (voltage > 3.00 ) {
usbMIDI.sendNoteOn(40, 127, 1);
voltage_Old = voltage;
//midiOLD = midiNeu ;
}
if (voltage < 1.00 ) {
usbMIDI.sendNoteOff(40, 0, 1);
voltage_Old = voltage;
//midiOLD = midiNeu ;
}
//delay(250);
{ Serial.print("voltage = ");
Serial.print(voltage);
Serial.print("\t");
Serial.print("voltage_Old = ");
Serial.print(voltage_Old);
Serial.print("\t");
Serial.print("midiOLD = ");
Serial.print(midiOLD);
Serial.print("\t");
Serial.print("midiNeu = ");
Serial.println(midiNeu);
}
while (usbMIDI.read()) { // Eingehende Nachrichten lesen und ignorieren !
}
}
How can I achieve that Note ON / Off is only output once when the threshold values are reached?
regards