Control Surface  1.2.0
MIDI Control Surface library for Arduino
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, 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 = {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
}
USBMIDI_Interface
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
Definition: USBMIDI_Interface.hpp:41
MCU::VUDecay::Default
constexpr unsigned int Default
Decay one segment/block every 150 ms if no new values are received.
Definition: VU.hpp:43
Control_Surface.h
The main header file that includes all Control-Surface header files.
MCU::VULEDs
Definition: VULEDs.hpp:46
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:68
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:203
MCU::VULEDs::toggleMode
void toggleMode()
Toggle the dot/bar mode.
Definition: VULEDs.hpp:75
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25