Shop OBEX P1 Docs P2 Docs Learn Events
WS2812 Project Help — Parallax Forums

WS2812 Project Help

livinlowelivinlowe Posts: 28
edited 2014-12-27 16:14 in Propeller 1
Hello everyone! I have a project in mind using 10 WS2812 leds that would light up sequentially starting from 1 to 10, with each LED starting black and smoothly lighting up to white (yellow, orange, red, then white kind of like an ember heating up to white hot). Been playing with Jonnymac's single shot demo program( Ive got the leds to cycle through colors with the demo program), and to be honest I'm over my head as i can't see any commands in the driver program that will set just one LED to a color, not the whole strip. Also, my programming skills are....well I don't have them! Yet, lol. Can anyone steer me to what commands in the driver program one would use to accomplish this task.

Thanks in Advance,

Shawn

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-12-21 13:00
    Is there a reason why you're using the single shot object? I was just looking at it myself and I think Jon's original object is easier to use.

    If you look at post #2 of the first link in the "Similar Threads" section, you'll see description of my "MergeColors" algorithm. It lets you blend colors between LEDs. It seems like it would be useful to your project.
  • TubularTubular Posts: 4,702
    edited 2014-12-21 13:52
    Shawn, welcome

    I've done something very similar. This code does what i think you requested - goes from black to red, through orange to yellow, then on to white, over a few seconds. You need Jon McPhalen's WS2812 driver from the obex

    ignore the 'phantom 1's comments'..


    obj
      strip : "jm_ws2812"                                           ' WS2812 LED driver.  Modified timing and drives 4 parallel outputs
    
    pub main | pos, i, j, k
      strip.start(LEDS, TotalPixels)                                 ' start led driver
      pause(10)
      pos:=1
      k:=89
      repeat
       repeat i from 0 to 269
          strip.set_rgb(i,0,0,0)                             ' phantom white pixels boost the average voltage (lots of 1's in data)
       pause(1800)
    
       repeat pos from 0 to 255
         repeat i from 0 to k
          strip.set_rgb(i,pos,0,0)
    '      pause(2)                            ' phantom white pixels boost the average voltage (lots of 1's in data)
       pause(800)
     
       repeat pos from 0 to 150
         repeat i from 0 to k
          strip.set_rgb(i,255,pos,0)                             ' phantom white pixels boost the average voltage (lots of 1's in data)
          pause(2)
       pause(700)
       repeat pos from 0 to 150
         repeat i from 0 to k
          strip.set_rgb(i,255,150,pos)                             ' phantom white pixels boost the average voltage (lots of 1's in data)
          pause(2)
       pause(1800)
      
    
  • T ChapT Chap Posts: 4,223
    edited 2014-12-21 20:01
    I am not sure what the one shot demo is, but this will set one LED if you have the OBJ LED: "jm_ws2812"

    Here are some examples:
    PUB Main    |    regcolor
        LED.start_b(LEDS, STRIP_LEN)                                ' start led driver
        FlashLed
        regcolor := LED.colorx(255, 0, 0, 255)             ' (r, g, b, level)   
        LED.set(0, regcolor)   '   led number,  color
    
    PUB LEDAllon      | regcolor
        regcolor := LED.colorx(255, 0, 0, 255)             ' (r, g, b, level)   
        waitcnt(1_000_000 + cnt)   'not sure why I put this  in
        LED.set_all(regcolor)
    
    
    PUB FlashLed
        LEDAllon
        waitcnt(5_000_000 + cnt)
        LED.off
        waitcnt(5_000_000 + cnt)
    
    
    
    
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-12-21 21:43
    Shawn,

    The only reason to use the single-shot version is if you want to control more than one physical string with the same cog. If you have just one output to the WS2812s, use my standard driver -- very easy.
  • livinlowelivinlowe Posts: 28
    edited 2014-12-27 13:16
    Okay working on it again! In the set.rgb function what is the channel value?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-12-27 13:20
    livinlowe wrote: »
    Okay working on it again! In the set.rgb function what is the channel value?

    The first LED in the stand is channel #0. You're just telling the method which LED to set.
  • livinlowelivinlowe Posts: 28
    edited 2014-12-27 16:14
    Duane Degn wrote: »
    The first LED in the stand is channel #0. You're just telling the method which LED to set.

    Ah! Okay thanks. BTW, I am now using the standard driver not the single shot
Sign In or Register to comment.