Shop OBEX P1 Docs P2 Docs Learn Events
How to make use of those RGB Leds with the stamps — Parallax Forums

How to make use of those RGB Leds with the stamps

Buck RogersBuck Rogers Posts: 2,186
edited 2013-02-21 19:29 in General Discussion
Hello!
One of the things I explored during my time away from the stamps was the (new to me) creation of the RGB LED. An individual pixel* contains a red one and a green one and then a blue one, with either a common anode, or common cathode. Now I've seen them used to create signage, and driving them was always an interesting turn. Then they were available in of all things, illumination.

At one point I bought one and then got the thing I was using then, to appropriately cycle through colors on it. Now I'm wondering if the same idea can be applied to a device and using the BS2 for the job. The units are either this one https://www.sparkfun.com/products/9264 who is indeed a common cathode variety, or a relative to this one https://www.sparkfun.com/products/10821 which is indeed common anode one. I say related because the original came from Radio Shack. And normally their site isn't normally easy to search but here goes: http://www.radioshack.com/product/index.jsp?productId=3020765&clickid=prod_cs .

Once I understood how they were driven without attached driving electronics, it was using PWM to do that, it was fairly easy.

Now I'm wondering if some of the ideas I never did get to work on that side of things, can be done here. That of having an RGB one change its colors in response to the data being sent to it, rather then just ordinary PWM pulses.
__________
*Picture element. Also most of them contain driver integrated circuits attached. These were the individual LEDs without them.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2013-02-03 15:13
    I am not really clear on exactly what you are asking. The intensities of the individual Red, Green, and Blue leds in the RGB led can be controlled either by PWM or analog (varying the current between 0 to the maximum current rating) means. If you want to send digital commands to set the intensity and color of the RGB leds you would need a controller that would accept those commands and use PWM or analog means to control intensity and color. PWM is the most common way of doing this.
  • Buck RogersBuck Rogers Posts: 2,186
    edited 2013-02-03 20:21
    kwinn wrote: »
    I am not really clear on exactly what you are asking. The intensities of the individual Red, Green, and Blue leds in the RGB led can be controlled either by PWM or analog (varying the current between 0 to the maximum current rating) means. If you want to send digital commands to set the intensity and color of the RGB leds you would need a controller that would accept those commands and use PWM or analog means to control intensity and color. PWM is the most common way of doing this.

    Have you used one before? I have. With the other thing and not the a***d*** one. It had the same form factor as it happens.

    So far I've not reached a working decision regarding any of mine but your remarks make sense.
  • kwinnkwinn Posts: 8,697
    edited 2013-02-03 21:14
    I used a few to make a simple little light organ. Used one 555 timer per color and a quad op amp to split the audio into 3 ranges to drive the control inputs of the 555's. A combination of PWM and frequency modulation of the brightness, but it looked pretty good.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-02-04 19:50
    Once I understood how they were driven without attached driving electronics, it was using PWM to do that, it was fairly easy.

    Now I'm wondering if some of the ideas I never did get to work on that side of things, can be done here. That of having an RGB one change its colors in response to the data being sent to it, rather then just ordinary PWM pulses.

    I've lately gone kind of LED crazy.

    I don't think there's a simple way of driving a RGB LED directly with a Basic Stamp. I think you could get away with driving a single RGB (or maybe two) with with a Stamp but the code would be pretty awkward. I posted some code in post #19 of this thread which I believe will drive a RGB LED with a wide range of possible colors using a BS2. I haven't tested the code with a BS2 so I'm don't know if it will work or not or if the PWM frequency will be too low and causes a noticable flicker. The values used in the code are intended to produce a white light. You can change the numbers to produce other colors (if the code works (I don't have the Basic Stamp editor installed on this computer)).

    Things get a lot easier with a Propeller when driving LEDs.

    One of my more recent LED projects use 8x8 RGB LEDs from ebay. I use shift registers to drive the many LEDs. I haven't updated the forum thread with the latest information on this project. I've had some PCBs made that make it a lot easier to drive these arrays. I'm planning on offering these PCB with for sale soon. This is the least expensive way I've found of having a bunch of RGB LEDs.

    An even easier (but more expensive) way of driving RGB LEDs is to used strips with WS2801 chips included with the LEDs. I used these strips to add RGB LEDs to my hexacopter.

    Another recent LED project used Christmas lights from CostCo. Here's a link to a rather boring demo (of the many thousands of possible colors, I only use two in the demo).

    I've just mentioned a few of the many ways to drive RGB LEDs (the ones I have experience with). I haven't ever tried kwinn's method of using 555 chips.

    Obviously I'm fond of RGB LEDs and I think they can really add some fun to a project.
  • Buck RogersBuck Rogers Posts: 2,186
    edited 2013-02-04 21:24
    Duane Degn wrote: »
    I've lately gone kind of LED crazy.

    I don't think there's a simple way of driving a RGB LED directly with a Basic Stamp. I think you could get away with driving a single RGB (or maybe two) with with a Stamp but the code would be pretty awkward. I posted some code in post #19 of this thread which I believe will drive a RGB LED with a wide range of possible colors using a BS2. I haven't tested the code with a BS2 so I'm don't know if it will work or not or if the PWM frequency will be too low and causes a noticable flicker. The values used in the code are intended to produce a white light. You can change the numbers to produce other colors (if the code works (I don't have the Basic Stamp editor installed on this computer)).

    Things get a lot easier with a Propeller when driving LEDs.

    One of my more recent LED projects use 8x8 RGB LEDs from ebay. I use shift registers to drive the many LEDs. I haven't updated the forum thread with the latest information on this project. I've had some PCBs made that make it a lot easier to drive these arrays. I'm planning on offering these PCB with for sale soon. This is the least expensive way I've found of having a bunch of RGB LEDs.

    An even easier (but more expensive) way of driving RGB LEDs is to used strips with WS2801 chips included with the LEDs. I used these strips to add RGB LEDs to my hexacopter.

    Another recent LED project used Christmas lights from CostCo. Here's a link to a rather boring demo (of the many thousands of possible colors, I only use two in the demo).

    I've just mentioned a few of the many ways to drive RGB LEDs (the ones I have experience with). I haven't ever tried kwinn's method of using 555 chips.

    Obviously I'm fond of RGB LEDs and I think they can really add some fun to a project.

    Hello!
    As it happens these devices are in fact the bare LED, that is without the driver chips, these WS2801 chips. This shop http://www.adafruit.com sells them as individual pixels, with the chips attached. They also sell the strips. Sparkfun http://www.sparkfun.com does also, (the strips not the pixels) they also sell the individual LEDs as well. I bought the three parts that I described earlier from the ITP (NYU Computer store) store here in Manhattan, but they had Sparkfun markings on the bags. However the widget that I alluded to in the beginning was bought from Microcenter in Yonkers, they sold me the BOE Shield for the pest, they also sell some of Parallax's wonders there as well.
  • Buck RogersBuck Rogers Posts: 2,186
    edited 2013-02-21 16:11
    Duane Degn wrote: »
    I've lately gone kind of LED crazy.

    I don't think there's a simple way of driving a RGB LED directly with a Basic Stamp. I think you could get away with driving a single RGB (or maybe two) with with a Stamp but the code would be pretty awkward. I posted some code in post #19 of this thread which I believe will drive a RGB LED with a wide range of possible colors using a BS2. I haven't tested the code with a BS2 so I'm don't know if it will work or not or if the PWM frequency will be too low and causes a noticable flicker. The values used in the code are intended to produce a white light. You can change the numbers to produce other colors (if the code works (I don't have the Basic Stamp editor installed on this computer)).

    Things get a lot easier with a Propeller when driving LEDs.

    One of my more recent LED projects use 8x8 RGB LEDs from ebay. I use shift registers to drive the many LEDs. I haven't updated the forum thread with the latest information on this project. I've had some PCBs made that make it a lot easier to drive these arrays. I'm planning on offering these PCB with for sale soon. This is the least expensive way I've found of having a bunch of RGB LEDs.

    An even easier (but more expensive) way of driving RGB LEDs is to used strips with WS2801 chips included with the LEDs. I used these strips to add RGB LEDs to my hexacopter.

    Another recent LED project used Christmas lights from CostCo. Here's a link to a rather boring demo (of the many thousands of possible colors, I only use two in the demo).

    I've just mentioned a few of the many ways to drive RGB LEDs (the ones I have experience with). I haven't ever tried kwinn's method of using 555 chips.

    Obviously I'm fond of RGB LEDs and I think they can really add some fun to a project.

    Hello!
    Well I glommed a copy of the code from that thread's post. And with minor tweaks that the editor insisted upon it tokenized properly. And now to wire it up and then try it out.

    Yours is the best idea I've seen so far for making use of these unique devices with the BASIC Stamp.

    As I stated earlier a shop (website only) in the city sells pixels wearing WS2801 chips so its possible to make use of the technology properly. My big problem is that those typically use the specialty functions that aren't available with the regular BASIC Stamp.

    http://www.adafruit.com/products/322 That there is the first set.

    http://www.adafruit.com/products/738 This is the second.

    Both are using that driver chip.

    If your code works, my next problem is working out how to feed data to the business from the outside.

    To use an RGB LED in a BASIC STAMP setup will require an external driving influence.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2013-02-21 18:42
    I have a NewHaven LCD display the RGB backlight and was able to crudely drive it with a BS2 using PWM.
    The flickering in the video was not noticeable to the eye....
    ' {$STAMP BS2}' {$PBASIC 2.5}
    
    
    lcd_cmd         CON    $FE   'command prefix
    displayOn       CON    $41   'Display ON
    displayOff      CON    $42   'Display off
    curpos          CON    $45   'set cursor  + position  (row 1=0 TO 15, row 2 = 64 TO 79)
    curHome         CON    $46
    ulCursOn        CON    $47   'Underline cursor on
    ulCursOff       CON    $48   'Underline cursor off
    curLeft         CON    $49
    curRight        CON    $4A
    blinkCursOn     CON    $4B   'Blinking cursor on
    blinkCursOff    CON    $4C   'Blinking cursor off
    backSpace       CON    $4E
    clrLCD          CON    $51
    contrast        CON    $52   '1 byte  1 to 50  DEFAULT 40
    backLight       CON    $53   'NOT USED for RGB
    custChar        CON    $54   '9 bytes
    scrollLeft      CON    $55
    scrollRight     CON    $56
    setBaud         CON    $61   '1 byte ENUM 300,1200,2400,9600,14400,19.2k,57.6k,115.2k
    setI2C          CON    $62   'set I2C addr - 1 byte  DEFAULT $50
    dispVer         CON    $70   'display firmware version
    dispBaud        CON    $71   'display Baud Rate
    dispI2C         CON    $72   'display I2C address
    
    
    #SELECT $STAMP                          ' Select Baud constants
      #CASE BS2, BS2E, BS2PE
        T1200       CON     813
        T2400       CON     396
        T4800       CON     188
        T9600       CON     84
        T19K2       CON     32
      #CASE BS2SX, BS2P
        T1200       CON     2063
        T2400       CON     1021
        T4800       CON     500
        T9600       CON     240
        T19K2       CON     110
      #CASE BS2PX
        T1200       CON     3313
        T2400       CON     1646
        T4800       CON     813
        T9600       CON     396
        T19K2       CON     188
    #ENDSELECT
    
    
    Inverted        CON     $4000           'Value for inverted serial format
    Baud            CON     T9600      '+ Inverted 8,N,1 inverted
    
    
    red   PIN 4   '12
    green PIN 2   '13
    blue  PIN 0   '14
    LCD   PIN 15
    
    
    OUTPUT red
    OUTPUT green
    OUTPUT blue
    LOW green
    LOW blue
    HIGH red
    
    
    bval VAR Byte
    rval VAR Byte
    gval VAR Byte
    dur  CON 2
    
    
    i VAR Byte
    
    
    PAUSE 500
    SEROUT LCD,Baud,[lcd_cmd, displayOn]
    PAUSE 500
    SEROUT LCD,Baud,[lcd_cmd, contrast, 30]
    PAUSE 500
    SEROUT LCD,Baud,[lcd_cmd, clrLCD]
    PAUSE 500
    SEROUT LCD,Baud,[lcd_cmd, blinkCursOff]
    PAUSE 1000
    SEROUT lcd,Baud,[lcd_cmd, curpos, 4, "NewHaven", lcd_cmd, curpos, 68, "RGB LCD"]
    PAUSE 1000
    'SEROUT LCD,Baud,[lcd_cmd, blinkCursOn]
    'PAUSE 2000
    
    
    
    
    'SEROUT lcd,Baud,[lcd_cmd2, $0A] 'ctrl-j
    'PAUSE 2000
    'SEROUT LCD,Baud,[lcd_cmd, clrLCD, noCurs]
    'SEROUT LCD,Baud,[lcd_cmd, curpos + 0,"Ron Czapala"]
    'PAUSE 500
    'SEROUT LCD,Baud,[lcd_cmd, curpos + 64,"Pippin"]
    'PAUSE 1000
    FOR i = 0 TO 5
     SEROUT LCD,Baud,[lcd_cmd, scrollRight]
     PAUSE 300
    NEXT
    LOW red
    HIGH green
    FOR i = 0 TO 5
     SEROUT LCD,Baud,[lcd_cmd, scrollLeft]
     PAUSE 300
    NEXT
    LOW green
    HIGH blue
    FOR i = 0 TO 5
     SEROUT LCD,Baud,[lcd_cmd, scrollRight]
     PAUSE 300
    NEXT
    HIGH red
    FOR i = 0 TO 5
     SEROUT LCD,Baud,[lcd_cmd, scrollLeft]
     PAUSE 300
    NEXT
    
    
    GOSUB cycle
    GOSUB DoPWM
    SEROUT LCD,Baud,[lcd_cmd, displayOff]
    END
    
    
    here:
      PAUSE 500
      GOTO here
    
    
      END ' Finished.
    'Backlight values: 128-157
    'SEROUT LCD,Baud,[lcd_cmd2, $8C]   '40% backlight
    'PAUSE 3000
    'SEROUT LCD,Baud,[lcd_cmd2, $96]   '73% backlight
    'PAUSE 3000
    'SEROUT LCD,Baud,[lcd_cmd2, $9D]   '100% backlight
    'PAUSE 1000
    'SEROUT LCD,Baud,[lcd_cmd2, $80]   'backlight off
    'SEROUT LCD,Baud,[lcd_cmd, displayOff]
    
    
    DoPWM:
     HIGH blue
     HIGH red
     HIGH green
     rval = 0
     bval = 255
     gval = 255
    
    
      FOR gval = 255 TO 0
        GOSUB LED_PWM
      NEXT
      gval = 0
    
    
      FOR rval = 0 TO 255
        GOSUB LED_PWM
      NEXT
      rval = 255
    
    
      FOR bval = 255 TO 0
        GOSUB LED_PWM
      NEXT
      bval = 0
    
    
      FOR gval = 0 TO 255
        GOSUB LED_PWM
      NEXT
      gval = 255
    
    
      FOR rval = 255 TO 0
        GOSUB LED_PWM
      NEXT
      rval = 0
    
    
      FOR bval = 0 TO 255
        GOSUB LED_PWM
      NEXT
      bval = 255
    RETURN
    
    
    LED_PWM:
      PWM red, rval, dur
      PWM green, gval, dur
      PWM blue, bval, dur
    RETURN
    
    
    Cycle:
      SEROUT LCD,Baud,[lcd_cmd, clrLCD]
      LOW green
      LOW blue
      HIGH red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "Red           "]
      PAUSE 1000
    
    
      HIGH green
      LOW blue
      LOW red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "    Green     "]
      PAUSE 1000
    
    
      LOW green
      HIGH blue
      LOW red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "          Blue"]
      PAUSE 1000
    
    
      LOW green
      HIGH blue
      HIGH red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "Red       Blue"]
      PAUSE 1000
    
    
      HIGH green
      LOW blue
      HIGH red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "Red Green     "]
      PAUSE 1000
    
    
      HIGH green
      HIGH blue
      LOW red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "    Green Blue"]
      PAUSE 1000
    
    
      HIGH green
      HIGH blue
      HIGH red
      SEROUT lcd,Baud,[lcd_cmd, curpos, 2, "Red Green Blue"]
      PAUSE 1000
    RETURN
    
    
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-02-21 19:29
    @Ron, That looks very cool. I know it's tough to try to make a video of LEDs. The video rarely looks as good as the real thing.

    @Buck, I think the WS2801 chips should be able to work with the Basic Stamp. The WS2801 uses a clock line so the Stamp could bit bang the data as slow as it pleases and the WS2801 should be able to receive the data. You may have trouble with the update rate if you try to use a bunch at once with a Basic Stamp.

    JonnyMac's code make the WS2801 pretty easy to use with the Prop. If you wanted to get the Prop a try I'm sure there'd be lots of people willing to help if you get stuck. (Oh good this isn't the Basic Stamp forum. I'm safe from erco's wrath.)

    I know LEDs are supposed to be basic stuff but I still think they're a lot of fun. I'm planning on making a 32x32 RGB LED array (24cmx24cm). I'm thinking it would be fun to use to play retro games like Pong or Breakout on it.
Sign In or Register to comment.