Page 36 of 46 FirstFirst ... 263435363738 ... LastLast
Results 351 to 360 of 459

Thread: RGB LED's Now Consumer Grade - Hackable?

  1. #351
    Join Date
    Dec 2010
    Posts
    22
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    Quote Originally Posted by Livermore-Dad View Post
    This is the color affects code. i've tried diamaunt walk code and it's not very happy with me. it seems to "Walk/chase for and aft", but leaves a single bulb somewhere on the line on.
    I did a little debugging, and the problem with your code is the
    if ( (((i+s)%50)<5 || (c == 0)
    line.

    here's a brief output of a little debugging:

    x:96 i:44 s:4 c:0
    x:96 i:45 s:4 c:0
    x:96 i:46 s:4 c:15
    x:96 i:47 s:4 c:15
    x:96 i:48 s:4 c:15
    x:96 i:49 s:4 c:15
    x:97 i:0 s:3 c:15
    x:97 i:1 s:3 c:15
    x:97 i:2 s:3 c:0


    you see when i+s is less than 5, it lights the light. 0+3%50 =3, which is < 5.

    I wouldn't brute force the whole string to zero almost all the time... it's probably just me, but I like only addressing the bulbs I'm changing.

    I'd suggest going with two loops, one going one way, the other going the other way. my head still hurts trying to figure out your algorithm, but that's prolly just my head. ;)

  2. #352
    Join Date
    Dec 2010
    Posts
    22
    Post Thanks / Like

    Default Re: Chase Chase Chase

    Quote Originally Posted by Livermore-Dad View Post
    Okay, friend helped with the code.

    It's a multi color fade chase that will go forward and back, it's really slick and what you can do with it is kick ass.
    slick!

  3. #353
    Join Date
    Nov 2010
    Location
    Livermore, CA
    Posts
    2,072
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    Quote Originally Posted by diamaunt View Post
    I did a little debugging, and the problem with your code is the
    if ( (((i+s)%50)<5 || (c == 0)
    line.

    here's a brief output of a little debugging:

    x:96 i:44 s:4 c:0
    x:96 i:45 s:4 c:0
    x:96 i:46 s:4 c:15
    x:96 i:47 s:4 c:15
    x:96 i:48 s:4 c:15
    x:96 i:49 s:4 c:15
    x:97 i:0 s:3 c:15
    x:97 i:1 s:3 c:15
    x:97 i:2 s:3 c:0


    you see when i+s is less than 5, it lights the light. 0+3%50 =3, which is < 5.

    I wouldn't brute force the whole string to zero almost all the time... it's probably just me, but I like only addressing the bulbs I'm changing.

    I'd suggest going with two loops, one going one way, the other going the other way. my head still hurts trying to figure out your algorithm, but that's prolly just my head. ;)
    thanks for this man and no, heck people's heads hurt just talking to me on a daily basis. There is what folks call, "tory speak". I start things mid thought, say things that make perfect sense to me but not quite to others

    I'm learning so any feedback, assistance is mucho appreciated

    Tory

  4. #354
    Join Date
    Nov 2010
    Location
    Livermore, CA
    Posts
    2,072
    Post Thanks / Like

    Default Re: Chase Chase Chase

    Quote Originally Posted by diamaunt View Post
    slick!
    Does that one make more sense? It should he's a programmer

    Tory

  5. #355
    Join Date
    Dec 2010
    Posts
    18
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    It works! I finally got my lights, some molex connectors, wired everything up, and now I'm golden. Good thing I'm going on vacation soon, because now the fun really starts. Thanks to everyone who's contributed, especially the brave souls who tried out my code and got it running properly.

  6. #356
    Join Date
    Apr 2010
    Location
    Austin,TX
    Posts
    21
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    Quote Originally Posted by bh758 View Post
    I have noticed a few other people on here asking for something simpler, like just being able to change the entire string to a preferred color. Although, I am sure it can be useful and neat in some situations, I really don't want to mess with 150 channels, lol.

    Any plans to come up with maybe a controller with 3 channels (RGB) for the entire sting? Maybe via 3 input voltage levels?

    What about being able to control the RGB of any entire string via LOR (for those of us who haven't spent the money on the DMX adapter yet)?

    Are there simpler and more straight forward methods coming to easily control them for those of us who aren't digital engineers, lol? (I would think this is where a bit of $ making might be done "on kits/boards" to make is simpler for those with other setups).

    Thanks!
    First of all the string of 50 lights would be 151 channels(light number 63). You could make channel 152, 153, 154 be a command to all lights in a string. I thought that the software(vixen) could be controlling 154 channels for each string of lights. It would be possible to ignore 151 channels and just use the 152,153,154 channels to program the whole strand.

    There would be a board say rgb controller board with two RJ45 one for input and one for output to the next board. Maybe power for the strand of lights, and a way to convert the signals from the RJ45 to control the lights in hardware and programmed chips(large task here). The board would need to use 160 channels so that it's div by 8. You may want to instead of using 151-154 for global commands use 157-160 for global commands.

    This sounds okay for one strand but if you wanted to control 5,10,... strands it would require a lot of channels. Vixen at 57600 baud rate at 50 ms is limited to 286 and just two strands of light would be 308.
    Last edited by holtzj; 12-23-2010 at 01:05 AM. Reason: Wrong original quote

  7. #357
    Join Date
    Dec 2010
    Posts
    22
    Post Thanks / Like

    Default Re: Chase Chase Chase

    Quote Originally Posted by Livermore-Dad View Post
    Does that one make more sense? It should he's a programmer

    Tory
    somewhat, but I'm trying to make it more of a cylon light, where it's bright, and fading, as the thing scans, instead of fading in and out, by making the array start at 15 and count down, but the way he's using the array, it causes it to fade in in one direction, and fade out when the lights reverse.

    change the array to 15, 13, 11, 9, 7, 5, 4, 3, 2, 1 and you'll see what I mean...

    too late tonight to wrap my head around his logic and figure out where to tweak it....

    I like it though.

  8. #358
    Join Date
    Dec 2010
    Posts
    4
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    Quote Originally Posted by Livermore-Dad View Post
    This is the color affects code. i've tried diamaunt walk code and it's not very happy with me. it seems to "Walk/chase for and aft", but leaves a single bulb somewhere on the line on.

    Code:
    #include "delay_x.h"
    #include "digitalWriteFast.h"
    
    const int lightPin = 4;
    const int bulbCount = 50;
    const int defaultIntensity = 0xBB;
    const int broadcastBulb = 63;
    
    void setup()
    {
      pinModeFast(lightPin, OUTPUT);
      digitalWriteFast(lightPin, LOW);
      _delay_s(1);
    
      //Enumerate the bulbs
      fillString(bulbColor(0,0,0));
    
      //fillString(bulbColor(0,15,0));
    }
    // CHASE SEQUENCE, Back and forth (get some blead over)
    void loop() {
    int s, c;
    for(int x=0; x<=100; x++) {
    s = x;
    if (x > 50) s = 100 - x;
    c = 15;
    if ((x == 0) || (x == 50)) c = 0;
    for(int i=0; i<bulbCount; i++) 
    {
    if ( (((i+s)%50)<5) || (c == 0) )
    setBulb(i, bulbColor( c, 0, 0 ));
    else
    setBulb(i, bulbColor( 0, 0, 0 ));
    }
    delay(75);
    }
    }
    
     
    
    void writeStart()
    {
    digitalWrite(lightPin, HIGH);
    delayMicroseconds(7);
    }
    
    void writeBit(int b)
    {
    switch (b)
    {
    case 0:
    digitalWrite(lightPin, LOW);
    delayMicroseconds(3);
    digitalWrite(lightPin, HIGH);
    delayMicroseconds(17);
    break;
    
    case 1:
    digitalWrite(lightPin, LOW);
    delayMicroseconds(17);
    digitalWrite(lightPin, HIGH);
    delayMicroseconds(3);
    break;
    }
    }
    
    void writeStop()
    {
    digitalWrite(lightPin, LOW);
    delayMicroseconds(32);
    }
    
    /*
     * Functions to set an individual bulb
     */
    
    int bulbColor(int r, int g, int b)
    {
      return (r+(g<<4)+(b<<8));
    }
    
    void setBulb(int bulb, int intensity, int color)
    {
      writeStart();
    
      for(int i=5; i>=0; i--)
        writeBit(bitRead(bulb, i));
    
      for(int i=7; i>=0; i--)
        writeBit(bitRead(intensity, i));
    
      for(int i=11; i>=0; i--)
        writeBit(bitRead(color, i));
    
      writeStop();
    }
    
    //If no inensity is specified, use the default
    void setBulb(int bulb, int color)
    {
      setBulb(bulb, defaultIntensity, color);
    }
    
    /*
     * Functions to set a series of bulbs or the entire string
     */
    
    void fillBulbs(int start, int count, int intensity, int color)
    {
      while(count--)
        setBulb(start++, intensity, color);
    } 
    
    //If intensity is not specified, use the default
    void fillBulbs(int start, int count, int color)
    {
      fillBulbs(start, count, defaultIntensity, color);
    } 
    
    //Fill the entire string
    void fillString(int intensity, int color)
    {
      fillBulbs(0, bulbCount, intensity, color);
    } 
    
    //Fill the entire string with the default intensity
    void fillString(int color)
    {
      fillBulbs(0, bulbCount, defaultIntensity, color);
    }
    I have not tested this code, but it should give good results. It is based on the code above. Give it a try.

    Code:
    //added consts
    //const int defaultIntensity = 187;    //0 to 255, duplicate definition
    const int minColor = 0;              //Leave alone
    const int maxColor = 47;            //256 * 3 -1; //Leave alone
    const int colorStep = 1;            //1 to  maxcolor
    
    const int minBulb = 0;               //Bulb index of min bulb
    const int maxBulb = 49;              //Bulb index of max bulb
    
    const int chaseLength = 5;           //maxBulb + 1 //1 to max num bulbs
    const int defaultStepDirection = 1;  //1 to maxBulb-1
    
    //replace loop code with this
    void loop() 
    {
        int currentColor = minColor; //minColor to maxColor
        int currentBulb = minBulb;   //minBulb to maxBulb-1
        int currentStepDirection = defaultStepDirection; //Leave alone
    
        while (true)
        {
            if (currentBulb > maxBulb + chaseLength) { currentStepDirection = -defaultStepDirection; currentBulb = maxBulb; }
            if (currentBulb < minBulb - chaseLength) { currentStepDirection = defaultStepDirection; currentBulb = minBulb; }
            setBulb(currentBulb, WheelRGB(currentColor));
            setBulb(currentBulb - (chaseLength * currentStepDirection), bulbColor(0, 0, 0));
            currentBulb += currentStepDirection;
            delay(75);
            if ((currentBulb >= minBulb) && (currentBulb <= maxBulb)) { currentColor += colorStep; }
            if (currentColor >= maxColor) { currentColor = minColor; }
        }
    }
    
    //replace the setBulb function with this one
    void setBulb(int bulb, int color)
    {
      if ((bulb < minBulb) || (bulb > maxBulb)) return;
      setBulb(bulb, defaultIntensity, color);
    }
    
    
    //add this function
    int WheelRGB(int WheelPosition)
    {
        if ((WheelPosition < 0) || (WheelPosition > maxColor)) return 0;
        if (WheelPosition < 16)//Red to Green
        {
            return bulbColor(15 - WheelPosition, WheelPosition, 0);
        }
        if (WheelPosition < 32)//Green to Blue
        {
            WheelPosition = WheelPosition - 16;
            return bulbColor(0, 15 - WheelPosition, WheelPosition);
        }
        if (WheelPosition < 48)//Blue to red
        {
            WheelPosition = WheelPosition - 32;
            return bulbColor(WheelPosition, 0, 15 - WheelPosition);
        }
        return 0;
    }
    It should chase forward then back repeatedly, all the while changing color from red to green to blue back to red etc...

    I don't have the lights yet, and I haven't complied the code, but you should be able to without too much problem, I hope. I did this just for fun, BTW.

    Regards,
    Clif
    Last edited by CougerAC; 12-24-2010 at 03:07 PM. Reason: changed scaling for colors from 0-255 to 0-15

  9. #359
    Join Date
    Dec 2010
    Posts
    22
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    Quote Originally Posted by CougerAC View Post
    I have not tested this code, but it should give good results. It is based on the code above. Give it a try.

    [CODE]

    I don't have the lights yet, and I haven't complied the code, but you should be able to without too much problem, I hope. I did this just for fun, BTW.

    Regards,
    Clif

    redefinition of defaultIntensity, using Delay instead of delay, just 'while' not 'do while' (why have an endless while loop inside of the loop() function?)...

    those things fixed, it's working, mostly, but, it leaves a light on here and there, seemingly at random, as it goes back and forth, plus, the colors aren't what you said you intended, they vary, but are pale cyan's, magenta's occasionally yellow, light green, somewhat inconsistent..

    cool otherwise! programming project grade: b ;)

  10. #360
    Join Date
    Dec 2010
    Location
    Avon Lake, OH
    Posts
    479
    Post Thanks / Like

    Default Re: RGB LED's Now Consumer Grade - Hackable?

    Has anyone tried these with the snowflake, Santa, or snowman figures of these lights. Saw them at Lowe's and they have the same pattern. I'm betting they are the same, but curious if anyone has checked yet.

    Erik

Page 36 of 46 FirstFirst ... 263435363738 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •