I wanted to add the possibility of a hardware reset so that I can start the Prioritron 3 (described by @Micraster in a known state. So I looked at the pins used and found that I could use pin D4 and the PCINT mechanism for this.
For this to work I added this library to my platformio.ini (VSC project) file
neu-rah/PCINT r-site.net@^4.0.8
And these few lines to the original code:
// define a pin for the external reset signal
#define RESET_PIN 4 // D4 = PCINT20
// include the library header file
#include <pcint.h>
// Define a software interrupt service routine.
// This will reset the sequencers to their 1st step
// and initiate the 1st step.
void reset_interrupt_service_routine(void) {
step = startStep;
noteDelay.start(tempo);
if (drumBool) {
playDrums();
} else {
playNote();
}
pulseCheck = 1;
digitalWrite(CLOCK_OUT, HIGH);
timeSinceLastClock = millis();
}
Near the end of the setup()-function these 2 lines need to be added:
pinMode(RESET_PIN, INPUT);
PCattachInterrupt<RESET_PIN>(reset_interrupt_service_routine, RISING);
The original code almost completely uses the available storage on the nano, so adding this code and the library made it an even more tight fit. At a rising signal on D4 the device will now reset either its note sequencer or drum sequencer and initiate the 1st step.
As the Prioritron does not have a spare input jack, I connected D4 via a resistor to pin 8 and 16 of a 16-pin flatcable connector (the 2nd resistor is a pull down resistor). In my rack I’ve designated pin 8 and 16 to be used as a ‘bus’ for a general purpose reset signal (see Reset-O-Matic), so this works nicely for me.