I would like to build a MIDI sequencer. I don't know how to implement a solid timebase to trigger midi events.

For instance, let's consider the way I could generate the MIDI clock "clics" using usbMIDI.sendRealTime(usbMIDI.Clock) function. This message is sent 24 times per quarter note. My idea would be to use an "elapsedMillis" variable. Here is the relation between midi tempo and clics period :
clic periode (ms) = 60 / tempo / 24 * 1000
if the tempo is set to 80, I have to send a clic every 31ms. The code would be something like :

elapsedMillis ticks
byte tempo = 80;

void sendTicks() {
  if (ticks > 60 / tempo / 24 * 1000) {
    ticks = 0;
Is it the right way ?
Can I use other elapsedMillis variable to trigger other midi events ?

Thank you