Shop OBEX P1 Docs P2 Docs Learn Events
RGB LED Controller — Parallax Forums

RGB LED Controller

Jason GulbinasJason Gulbinas Posts: 17
edited 2009-05-28 17:22 in BASIC Stamp
Hello,

I am new to STAMP and am using the BS2. I have successfully built some cool LED projects but want to now take it to the next level with some LED control.

I am looking to control a typical RGB LED so that I can change brightness/color. If I have independent control of each color then I will be able to get some cool oranges and yellos, etc. out of the RGB LED.

Apparently there are some "off-shelf" options available for doing this such as the ShiftBright (which looks like a board and LED controller combo all in one):

http://macetech.com/store/index.php?main_page=product_info&cPath=1&products_id=1

My question:

Is there a way to build an LED controller on the Parallax BOE by using basic components (perhaps a controller IC from TI or Allegro (like the A6281)) or would it be easier to just buy the ShiftBrite?

If the ShiftBrite is the answer does anyone have any example code and schematics of how to hook it up to the Stamp and control it?


Thanks so much!
Jason

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-05-27 06:34
    Take a look at the TLC5940. It's a chip that I've been meaning to try just for this purpose.
  • Jason GulbinasJason Gulbinas Posts: 17
    edited 2009-05-27 06:43
    Thanks for the reply!

    The TLC5940 I am sure would be a great solution but I am a beginner and know enough to get me to the level where this component and the RGB LED is placed onto the breadboard. I would be clueless of the interconnect between the Stamp and the IC and the IC to the LED. Then there is the challenge of figuring out what code to use to control the circuit!!

    I could try to figure this out though and am willing to do the work. I am sure there may be some example code somewhere of Basic code that is used to control the TLC5940, and connecting it to the LED (configuration/wiring) cant be too hard.


    Thanks!
  • Jason GulbinasJason Gulbinas Posts: 17
    edited 2009-05-27 18:26
    I am aware that the basic stamp has a PWM command that allows you to control the brightness of an LED. With that said, can't I control the brightness of the R G and B independently WITHOUT the TI TLC5940 or other external controller component? Wouldn't this allow me to generate different colors from an RGB LED withour an extra LED PWM controller.

    This question may be naive but hey...that's how we learn!! Thanks for the support.
  • BeanBean Posts: 8,129
    edited 2009-05-27 18:56
    The PWM command can only generate PWM on 1 pin at a time.

    If you don't need alot of different colors you can use several pins with different value resistors to control each element of the RGB LED.

    For example if you used 4 pins for each element is would take 12 pins and allow for 4096 (16*16*16) different colors.

    Here is the breakdown of pins vs colors:

    1 pin per element = 8 (2*2*2) colors
    2 pins per element = 64 (4*4*4) colors
    3 pins per element = 512 (8*8*8) colors
    4 pins per element = 4096 (16*16*16) colors

    I use the term "color" loosely here. There are shades of white, etc...

    For the resistors you basically double the resistor value for each new resistor. Making sure that when all pins are high, the current through the LED will not burn it up.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • Jason GulbinasJason Gulbinas Posts: 17
    edited 2009-05-27 19:08
    Thanks Bean,

    I do only need a few colors here. A red, an orange, a yellow, a green and a blue. But I want them to fade nicely into each other...which is why I am not using discrete color LEDS.

    Your solution may provide the cheapest way to accomplish this...and doesnt look too challenging.

    I do wonder how easy it would be just to buy and implement the ShiftBrite module or TI LED PWM controller. Do you think it would be easier to buy and learn about the TI5940?

    I will post more on the solution once I figure it out!!


    Thanks,
    Jason
  • macegrmacegr Posts: 5
    edited 2009-05-27 22:05
    The SHIFTOUT command is all that would be required to control my ShiftBrites, or Brilldea's PolkaDOTs for that matter. The A6281 only comes in a 3mm QFN-16. The A6280 comes in DIP, but requires an external PWM clock source. The TLC5940 also requires an external clock source.

    The guys on the EFX-TEK forums got the ShiftBrite working with a BS2 exactly one year ago: www.efx-tek.com/php/smf/index.php?topic=620.0
  • UghaUgha Posts: 543
    edited 2009-05-27 23:19
    Another option would be digital pots to adjust the resistance of the connections to each color of the LED. This may not be as fast of a transition as you'd like though.

    What I would do, simply because it doesn't require any additional components and well, I'm cheap, is fake PWM:

    If you don't need your BS2 to do anything but control the LED... you can send a series of highs and lows (or better yet, assign the pins 0s and 1s once they are set as output) in a
    loop to fade the different colors together in any way you want at any pace you want.
    Unfortunately, the BS2 isn't very fast. This may show up as a slightly dimmer than normal light coming from the LED.

    Experiment with different mixes of 1s and 0s to get the various colors you want. (this will take a long time most likely)
  • Jason GulbinasJason Gulbinas Posts: 17
    edited 2009-05-28 03:40
    Thanks all for the help. I am going to buy a few ShiftBrites and also try a few of the other methods just to learn the options. I will repost with what I end up with and the code I end up using. This forum is great!

    -Jason
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-28 06:01
    Jason,

    Normally, I'd play my cards a little closer to the vest. But your post demands a revelation that I just couldn't hold back. So, with Ken Gracey's blessing, I can reveal a forthcoming product from Parallax that I had a hand in developing: the ColorPAL. The ColorPAL is actually two products in one:

    ····1. A color sensor that complements, for the hobbyist market, the capabilities of the TCS230-DB, and

    ····2. A scriptable color generator that uses the onboard RGB LED to generate and blend a full gamut of user-programmable colors.

    The ColorPAL interfaces to the BASIC Stamp (and other controllers) through a standard three-pin servo header and uses serial I/O to communicate commands and data. It includes the aforementioned RGB LED, an onboard microcontroller, and a TAOS light-to-voltage detector, along with a collimating shroud for the color detection function.

    I've attached the users' manual for this product below, along with a zip of a movie highlighting some of the color blending capabilities.

    I'm not going to comment on when the ColorPAL will be available or for how much. I've seen Ken's projections, and ... well ... if he wants to weigh in here, he can. smile.gif

    -Phil
  • FireHopperFireHopper Posts: 180
    edited 2009-05-28 12:15
    you can also try the blinkm from sparkfun, I think some bs2's have i2c sending commands, thats all you need to controll a blinkm.
  • Jason GulbinasJason Gulbinas Posts: 17
    edited 2009-05-28 17:22
    Thanks Phil...sounds like a great product and one that I would like to try out...thanks also FireHopper for the advice for the BlinkM.

    I looked at the manual for the BlinkM and found it to be VERY helpful....not only does it comprehensively describe how to hook the BlinkM up to the Stamp Board but it also give example code. The ShiftBrite is all I need for my application but it lacks the documentation that the BlinkM has....it is also much more economical. The BlinkM seems to have an onboard memory that don't really need since I will always be hooked up to my Board of Education.

    Thanks all for the help. I thought that it must be easy and normal to try and control an RGB LED...especially now that we see a ton of off-shelf LEB bulbs that change colors and brightness by remote control.
Sign In or Register to comment.