View Single Post
  #11   Spotlight this post!  
Unread 05-03-2016, 04:59
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 684
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Help needed with algorithm

In regards to the code
Code:
  float in, out;

  for (in = 0; in < pi * 2; in = in + pi/500)
  {
    for (int i = 0; i <= 23; i = i + 1)
    {
      if (in > pi * 2 * i / 24 )
      {
        out = ((cos((in - pi) - (i*(pi*2)/24))+1)/2) *4095;
        tlc.setPWM(i, out);
        tlc.write();
      }
    }
  }
I don't think this does what you think it does.

Running it thru a spreadsheet, that if (in > pi * 2 * i / 24 ) only is true for 1 of the 24 i loops, so re-sets the LED 1/24th of the time. Good practice is setting the LED each loop, even if it is off, because the LED will keep the previous number until changed.

When it does set the LED, out is in a range from zero to the low 4000s. If these LEDs are typical, the range is zero (off) to 255 (full on). Plus if they are color, you have to set each Red-Green-Blue to a level -- typically something like

tlc.setPWM( i, color( outR,outG,outB ) );

Find the command in the examples; I'm just guessing what it is.
Reply With Quote