Enable-disable
This example shows how to dynamically enable or disable specific MIDI elements.
- Boards: 🛈
- AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Teensy 3.x, ESP32, ESP8266
Connections
- 2: momentary push button (to ground)
- A0: wiper of a potentiometer
The internal pull-up resistor for the button will be enabled automatically. Connect the left terminal of the potentiometer to ground, and the right one to VCC.
Behavior
At program start-up, the potentiometer is enabled, and it sends MIDI Pitch Bend messages when its position changes. By pressing the push button, the potentiometer is disabled (this is indicated by the on-board LED turning off). When disabled, Control Surface stops sampling the analog input of the potentiometer, and no Pitch Bend messages are sent for this MIDI output element (any other elements are unaffected). Pressing the push button again enables the potentiometer again.
Written by PieterP, 2018-07-26
https://github.com/tttapa/Control-Surface
void setup() {
digitalWrite(LED_BUILTIN,
HIGH);
}
void loop() {
if (enableButton.
getState() == Button::Falling) {
static bool state =
true;
state ? masterVolume.enable() : masterVolume.disable();
}
}
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
constexpr Channel Channel_9
The main header file that includes all Control-Surface header files.
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
void begin()
Initialize the Control_Surface.
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
A class of MIDIOutputElements that read the analog input from a potentiometer or fader,...
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.