Controlling 128 LEDs via MIDI

We want to set/clear LEDs, which are connected to one or more DOUTX4 modules, with Note Events over MIDI Channel #1

Copy the SDCC skeleton into a new directory, open the main.c file and enhance the hooks like described below. Thereafter type "make" in the command shell, and upload the new project.hex file to the core.

Within the Init() function, you have to specify, how many shift registers are connected to the core:

// This function is called by MIOS after startup to initialize the 
// application
void Init(void) __wparam
  // set shift register update frequency
  MIOS_SRIO_UpdateFrqSet(1); // ms

  // Up to 4 DOUTX4 modules (=16 shift registers = 128 digital outputs) can be connected
  // set the maximum number here - it doesn't really hurt!

//  This function is called by MIOS when a complete MIDI event has been received
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (->
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(pin, 1);


A list of available MIOS function can be found here.

Last update: 2018-03-05

Copyright 1998-2018, Thorsten Klose. All rights reserved.