A better LED circuit for MIDI activity indicator

Status
Not open for further replies.

yeahtuna

Well-known member
I have a MIDI out port with an LED and 220 ohm resistor connected between pins four and five to serve as a MIDI activity indicator. The trouble is that MIDI messages are so short, that the LED is barely visible. Is there some other circuit I could make with a transistor or some other component to make the LED light for longer? I have no free iO pins, so that is not an option.

Regards,
Rob
 
I have a MIDI out port with an LED and 220 ohm resistor connected between pins four and five to serve as a MIDI activity indicator. The trouble is that MIDI messages are so short, that the LED is barely visible. Is there some other circuit I could make with a transistor or some other component to make the LED light for longer? I have no free iO pins, so that is not an option.

Regards,
Rob

yeahtuna:

I needed this exact same thing in my TeensyMIDIPolySynth project. I ended up using a (boolean-like) variable to control driving the LED.

Code:
int midi_note_activity_state = false;

I also defined another variable that is used in the timing of illuminating & extinguishing the LED (& the defined duration):

Code:
// keep track of how long to light the MIDI activity LED
#define ACTIVITY_LED_DURATION_MILLIS 5
unsigned long led_time;

Here's an example of when the "boolean" variable is set:

Code:
// MIDI message callback - note on
void handleNoteOn(byte channel, byte pitch, byte velocity)
{
   midi_note_activity_state = true;

   . . .
}  // handleNoteOn()

And, inside of the loop() function, here's the code that actually illuminates the LED for the defined period:

Code:
      if (midi_note_activity_state == true)
      {
         digitalWrite(MIDI_NOTE_ACTIVITY_LED_PIN, HIGH);
      }

      led_time = millis();
      midi_note_activity_state = false;

      while ((midi_note_activity_state == false) && ((millis() - led_time) < ACTIVITY_LED_DURATION_MILLIS)) {};

      digitalWrite(MIDI_NOTE_ACTIVITY_LED_PIN, LOW);

All of this together causes the LED to turn on when activated & to normally stay on for the defined duration. If another call sets the "boolean" while the LED is illuminated, The LED will flicker quickly (with each subsequent call) & stay on for the defined duration of the last activity.

I have another set of variables for the "midi_control_activity_state" that are used to drive another LED for control messages, but did not include that additional functionality here in an attempt to minimize complexity/confusion. These two together provide a nice real-time indication of my incoming MIDI messages.

Hope that helps . . .

Good luck & have fun !!

Mark J Culross
KD5RXT
 
Thanks, Mark. Unfortunately, as stated in the first post, I have no free iO pins.

yeahtuna:

So sorry, I definitely should have read your post more closely !! Can you take some of the I/O currently in use & combine thru a 74HC4067 16-to-1 analog MUX (for input sampling) or a 74HC595 (for output driving) to free up some pins ?? Otherwise, the 555 approach sounds like it would work.

Good luck & have fun !!

Mark J Culross
KD5RXT
 
I changed my led from green to orange and that has made a world of difference. No need for anything fancier.
 
Status
Not open for further replies.
Back
Top