Hello Forum,
I'm just starting out on programming, and I've had to forcefully start a code for a 3-position on-off-on switch with 3 pins. 1,2,3 or L, C and R (Left, Center and Right)
One connects to ground and the other two to two digital pins.
The idea is to send MIDI CC # messages at each switch position.
I still need to define when position 1 is off and position 3 is off, that is, the switch is in position 2, or central, make the code for this.
I was able to assign MIDI CC # to each end position.
The question is how to stop sending the message, when the switch is set to 1 or 3 (L or R)
In Hairless Midi it continues to send the message eternally, depending on the delay you place on it.
This is the code:
#include <MIDI.h>
int sw_L = 6;
int sw_C ; // falta definir cuando sw_L =off y sw_R =off, así Center =on
int sw_R = 5;
void setup()
{
Serial.begin(115200); //hairless + loop midi (via usb - pc) descargar hairless y loop midi - conecta con PEDALERA gt-1000 a traves de loopmidi
//-----------------/ SETUP - INTERRUPTOR 3 POS /--------------------------
pinMode (sw_L, INPUT_PULLUP);
pinMode (sw_R, INPUT_PULLUP);
}
//-----------------/ LOOP - INTERRUPTOR 3 POS /--------------------------
if (digitalRead(sw_L)==LOW){
MIDI.sendControlChange(8, 0, 1);
delay(200);// no se detiene el envio del mensaje
}
if (digitalRead(sw_R)==LOW){
MIDI.sendControlChange(8, 127, 1);
delay(200);// no se detiene el envio del mensaje
}
//-----------------/ end LOOP - INTERRUPTOR 3 POS /--------------------------
}