View Single Post
  #1   Spotlight this post!  
Unread 03-03-2016, 22:33
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Help needed with algorithm

Hello.
I am finally got to seriously play with Arduino boards and want to control bank of 24 LEDs. Idea at the moment is to create a single wave of light. I thought I was on the right track, but results are not what I expected.
Here is my code snippet:
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();
      }
    }
  }
There must be a simple solution for this and it just escapes me.
Any help is appreciated
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote