Jump to content

Control LEDs without HC595


FantomXR

Recommended Posts

Hey people,

Maybe you can guide me in the right direction. 

In my projects I use buttons with integrated LEDs. But I want to get away from the standard HC595. Mainly because it takes a lot of PCB space and it has a lot traces due to the SPI protocol. 

Is there another style to control those LEDs? I also work a lot with WS2812. This is great because there is only one single data line from one to the next. 

Thanks,

Chris

Link to comment
Share on other sites

  • 3 weeks later...

Alright... I've got a solution that works great for me. I thought I share it with you.

I now tried WS2811 driver ICs. They are cheap and only need one data-line which goes from one IC to the next. Each IC can drive three LEDs. Of course you are not really capable to control them individually with standard NG code. So I've added a meta command.

Add this to mbng_event.c (row 2968 and following):
 

  case MBNG_EVENT_META_TYPE_RGB_LED_SET_SINGLE:      return "RgbLedSetSingle";

row 3055 and following:

  if( strcasecmp(meta_type, "RgbLedSetSingle") == 0 )       return MBNG_EVENT_META_TYPE_RGB_LED_SET_SINGLE;

row 3142 and following:

  case MBNG_EVENT_META_TYPE_RGB_LED_SET_SINGLE:     return 3;

row 3376 and following:


    case MBNG_EVENT_META_TYPE_RGB_LED_SET_SINGLE: {
      u16 led;
      if( (led=meta_values[0]) ) {
	led -= 1;
	WS2812_LED_SetRGB(led, meta_values[1], meta_values[2]);
      }
    } break;

 

in mbng_event.h add this line 163 and following:

  MBNG_EVENT_META_TYPE_RGB_LED_SET_SINGLE,

 

Done! Now you can call the meta RGBLEDSETSINGLE from NG. Here is a quick example. I had no buttons connected to that midibox. So I've worked with receivers and senders:

EVENT_RECEIVER id=1 type=cc cc=2 if_equal=127 fwd_id=SENDER:1
EVENT_RECEIVER id=1 type=cc cc=2 if_equal=0   fwd_id=SENDER:2

EVENT_SENDER id=1 type=meta meta=rgbledsetsingle:1:1:255
EVENT_SENDER id=2 type=meta meta=rgbledsetsingle:1:1:0

This switches on the second LED of the first IC on if CC2 with a value of 127 is received. It switches off when 0 is received. 

So you can control each LED individually without overwriting the other :-)
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...