Looking for some guidance on programming some Neopixels

So I have some code that I have that runs a sequence on s custom PCB with neopixels. I am using an Arduino nano to run the sketch. What I am looking to do is change the number of pixels that I can illuminate at a time and make it so I can control the movement from input from something like and RC transmitter.

Here is the code:

#define NUM_LEDS 41

#define BRIGHTNESS 100

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);

byte neopix_gamma[] = {
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,
  2,  3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  5,  5,  5,
  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  9,  9,  9, 10,
  10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
  17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
  25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
  37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
  51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
  69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
  90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 109, 110, 112, 114,
  115, 117, 119, 120, 122, 124, 126, 127, 129, 131, 133, 135, 137, 138, 140, 142,
  144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 167, 169, 171, 173, 175,
  177, 180, 182, 184, 186, 189, 191, 193, 196, 198, 200, 203, 205, 208, 210, 213,
  215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255
};


void setup() {
  strip.setBrightness(BRIGHTNESS);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Some example procedures showing how to display to the pixels:
  //colorWipe(strip.Color(255, 0, 0), 50); // Red
  //colorWipe(strip.Color(0, 255, 0), 50); // Green
  //colorWipe(strip.Color(0, 0, 255), 50); // Blue
  //colorWipe(strip.Color(0, 0, 0, 255), 50); // White

  //whiteOverRainbow(20,75,5);

  //pulseWhite(5);

  // fullWhite();
  //delay(50);

  //rainbowFade2White(3,3,1);

  RobotEYE_center  ();
  delay(1000);
  RobotEYE_right1   ();
  delay(50);
  RobotEYE_right2   ();
  delay(50);
  RobotEYE_right3   ();
  delay(50);
  RobotEYE_right4   ();
  delay(1000);
  RobotEYE_down    ();
  delay(50);
  RobotEYE_down_1  ();
  delay(50);
  RobotEYE_down_2  ();
  delay(50);
  RobotEYE_down_3  ();
  delay(600);
  RobotEYE_up_1  ();
  delay(50);
  RobotEYE_up_2  ();
  delay(50);
  RobotEYE_up_3  ();
  delay(50);
  RobotEYE_up_4    ();
  delay(1000);
  RobotEYE_left     ();
  delay(50);
  RobotEYE_left1     ();
  delay(50);
  RobotEYE_left2     ();
  delay(50);
  RobotEYE_left3     ();
  delay(1000);
  RobotEYE_up5     ();
  delay(50);
  RobotEYE_up6     ();
  delay(50);
  RobotEYE_up7     ();
  delay(50);
  RobotEYE_up8     ();
  delay(1000);
   RobotEYE_down5     ();
  delay(50);
  RobotEYE_down6     ();
  delay(50);
  RobotEYE_down7     ();
  delay(50);
  RobotEYE_down8     ();
  delay(1000);
}


void RobotEYE_center () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(20, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_right1 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(28, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_right2 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(34, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_right3 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(38, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_right4 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //Red
  strip.setPixelColor(40, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(39, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down_1 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(32, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down_2 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(31, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down_3 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(16, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up_1 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(17, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up_2 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(18, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up_3 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(19, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up_4 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }
  //red
  strip.setPixelColor(20, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_left () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(12, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_left1 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(6, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_left2 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(2, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_left3 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(0, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up5 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(1, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up6 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(8, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up7 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(9, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_up8 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(24, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down5 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(23, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down6 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(22, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down7 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(21, strip.Color(255, 0, 0, 0) );

  strip.show();
}

void RobotEYE_down8 () {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0) );
  }

  //Red
  strip.setPixelColor(20, strip.Color(255, 0, 0, 0) );

  strip.show();
}

Here is a picture of the setup and a video.

In what pattern do you want to illuminate more than one LED?

Blackfin:
In what pattern do you want to illuminate more than one LED?

I want to illuminate more of the pixels so the overall effect is bigger. Like a circle of 6 at a time. Then I want to be able to control the movement by RC control. Right now it's all automated by the sketch.

Here is a video with cover that it will have.

http://youtu.be/PiFUVunDlmI

On the surface I think illuminating more than one LED will present a bit of a challenge.

Your board's LED pattern is symmetrical but it's not continuous and it's sort of "coarse". It would be tough to get even illumination in the areas where the LEDs are spaced further apart compared to, say, the center where you have 9 LEDs closely packed.

Right now your LEDs look like:

                                            25
                                            
                                            
                                10          24          26
                                
                                
                    9           11          23          27          37
                    
                    
                2       8           12      22      28          36      38
                
                
            1       3       7       13      21      29      35      39      41
            
            
                4       6           14      20      30          34      40
                
                
                    5           15          19          31          33
                    
                    
                                16          18          32
                                
                                
                                            17

If your RC decoding put you at the coordinate where LED 15 is located the LED pattern would look vastly different than at LED 21.

In theory you could use two RC channels -- one for X, one for Y -- and some math to give polar coordinates in a Cartesian space. That space, overlaid on your LED pattern, could give you the "nearest" LED as the center of the pattern. You could place a small mathematical "circle" at that point and identify all LEDs within the area of that circle and those would be the ones you light.

In theory.

But the result might be less than satisfying given the relatively small number and irregular spacing of the LEDs.

I see....This seems like it will be a tough road. Time to do some more reading.

Thanks for the input.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.