Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
4.VULEDs.ino

4.VULEDs

This example demonstrates the use of the VULEDs class that displays the VU or level meters from your DAW as an LED bar graph.

Shift registers are used to drive the LEDs.

Boards: 🛈
AVR, AVR USB, Nano Every, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Due, Teensy 3.x, ESP8266, ESP32

Connections

Connect an LED (and series resistor) between each of the first 12 outputs of the shift registers and ground.

Remember to connect the enable pin of the shift register to ground and the master reset pin to Vcc in order to enable it.

Behavior

The LEDs display the level of the first track in your DAW.
When the push button is pressed, the VU meter switches from bar mode to dot mode and back.

Mapping

Map the Arduino as a Mackie Control Universal in your DAW.

Written by PieterP, 2019-12-09
https://github.com/tttapa/Control-Surface

// Instantiate two daisy-chained shift register with the SPI slave select pin as
// latch pin, most significant bit first, and a total of 16 outputs.
SPIShiftRegisterOut<16> sreg {SPI, SS, MSBFIRST};
// Instantiate a VULEDs object with 12 LEDs.
sreg.pins().slice<0, 11>(), // first 12 pins of the shift registers
1, // track number [1, 8]
MCU::VUDecay::Default, // how long does it take for the meter to decay
};
// If you don't want to use shift registers, you can just specify a list of pin
// numbers:
//
// MCU::VULEDs<12> vu {
// {{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}, // Arduino pin numbers
// 1, // track number [1, 8]
// MCU::VUDecay::Default, // how long does it take for the meter to decay
// };
// You can also use a different number of LEDs, but keep in mind that the MCU
// protocol sends the level on a scale from 0 to 12.
// If you use 24 LEDs, for example, the LEDs will turn on in groups of 2 at a
// time.
// Push button to switch between dot and bar mode.
Button dotBarModeButton = A0;
void setup() {
dotBarModeButton.begin();
}
void loop() {
if (dotBarModeButton.update() == Button::Falling) // when button is pressed
vu.toggleMode(); // toggle between dot and bar mode
}
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 MIDI input element that represents a Mackie Control Universal VU meter and displays its value using...
Definition VULEDs.hpp:43
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
constexpr unsigned int Default
Decay one segment/block every 150 ms if no new values are received.
Definition VU.hpp:179