Jan Ostman
Published

DIY USB2DIN Sync

Sync your Roland drum machine to your DAW through USB.

IntermediateProtip1 hour1,658
DIY USB2DIN Sync

Story

Read more

Code

Code snippet #1

Plain text
void usbFunctionWriteOut(uchar * data, uchar len) {
  if (data[1] == 0xF8) { //If Clock
    CLKcnt=500; //Reset clock counter to 2mS
    digitalWrite(5,HIGH); //Set clock output
  }
  if (data[1] == 0xFA) { //If Start
    digitalWrite(2, HIGH); //Set Start/Stop HIGH
  }
  if (data[1] == 0xFC) { //If Stop
    digitalWrite(2, LOW); //Set Start/Stop LOW
  }
}

Code snippet #2

Plain text
#include <DigiMIDI.h>;
DigiMIDIDevice midi;

void setup() {
  pinMode(2,OUTPUT); // Run/Stop is output
  pinMode(5, OUTPUT); //Clock is output

  digitalWrite(5,LOW); //Set initial Clock to LOW;
  digitalWrite(2,LOW); //Set initial Run/Stop to LOW;
}
void loop() {
  midi.update(); //Check if any MIDI data is received
  if (CLKcnt) { //Ongoing clock pulse?
    CLKcnt--;
    if (!CLKcnt) digitalWrite(5,LOW); //Reset clock output
  }
}

Github

https://github.com/heartscrytech/DigisparkMIDI

Credits

Jan Ostman

Jan Ostman

34 projects • 159 followers
I'm an embeddeds wizard that can turn any pile of electronic junk to something really great. Mc Gyver style.

Comments