Control Surface  1.1.1
MIDI Control Surface library for Arduino
3.NoteLEDBar.ino

3.NoteLEDBar

This example demonstrates the use of LED bar graphs that respond to incoming MIDI note events. The LEDs are driven by a 74HC595 (or equivalent) shift register.

Boards:
AVR, AVR USB, Teensy 3.x, ESP32

Connections

Connect eight LEDs (and series resistors) between the outputs of the shift register 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

If a MIDI Note On event for note 0x3C (C4 or middle C) is sent, the LED bar display is turned on, the higher the velocity (the harder you press the key), the more LEDs will turn on.

Mapping

Route the MIDI output of a MIDI keyboard or from an audio workstation to the Arduino's MIDI input.

Written by PieterP, 2019-11-25
https://github.com/tttapa/Control-Surface

// Include the library
// Instantiate a MIDI Interface to use
// Instantiate a shift register as output for the LEDs
SPIShiftRegisterOut<8> sreg = {
10, // Latch pin (ST_CP)
MSBFIRST, // Byte order
};
using namespace MIDI_Notes;
// Create a LED bar driver that listens for MIDI Note C4 that drives
// the LEDs connected to the eight output pins of the shift register
NoteLEDBar<8> leds = { sreg.pins(), note(C, 4) };
// Initialize the Control Surface
void setup() {
}
// Update the Control Surface
void loop() {
}
/*
* Extra
* =====
*
* 1. The exact same approach can be used to make a LED bar graph that shows
* the value of a Control Change input.
* In that case, use CCLEDBar instead of NoteLEDBar.
*
* 2. You can use any type of pins for the LEDs, and in any combination.
* For example, if you want to use the normal Arduino pins 2-9:
*
* NoteLEDBar<8> leds = {
* {{2, 3, 4, 5, 6, 7, 8, 9}},
* note(C, 4),
* };
*
* Note the use of double braces for the list of numbers.
*
* You can even mix and match pins of different types:
*
* NoteLEDBar<8> leds = {
* {{2, 3, 4, 5, 6, 7, sreg.pin(0), sreg.pin(1) }},
* note(C, 4),
* };
*/
Control_Surface.h
The main header file that includes all Control-Surface header files.
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:48
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:176
MIDI_Notes::note
constexpr int8_t note(int8_t note, int8_t numOctave)
Get the MIDI note in the given octave.
Definition: Notes.hpp:35
NoteLEDBar
Class that listens for Note events and displays the velocity on an LED Bar Graph.
Definition: NoteCCRangeLEDBar.hpp:52
USBDebugMIDI_Interface
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
Definition: DebugMIDI_Interface.hpp:115
MIDI_Notes
MIDI note names.
Definition: Notes.hpp:16
MIDI_Notes::C
constexpr int8_t C
Definition: Notes.hpp:18
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25