This sketch implements a MIDI beat clock driver which can be controlled by tapping a button or pedal (such as a digital keyboard sustain pedal) connected to the Arduino. Holding the button/pedal down for 1 second stops the beat messages until a new tempo is tapped in.
The default pinout I used for building a compact unit out of an Arduino Nano is as follows:
- External power supply (5-20V) to pins
VIN
andGND
- Button or pedal to pins
GND
and14
akaA0
(used inINPUT_PULLUP
mode) - MIDI DIN connector pin 2 to Arduino
GND
- MIDI DIN connector pin 4 to Arduino pin
5V
through a 220 Ohm resistor - MIDI DIN connector pin 5 to Arduino pin
10
through a 220 Ohm resistor - Status LED to Arduino pin
6
(through a suitable resistor) andGND
Since the MIDI messages are not sent via the hardware serial interface, it is also possible to run the Arduino off USB power and use the normal Serial monitor for debugging.
This sketch requires two libraries, both available for download from within Arduino: