Help with 8x17 LED Neopixel Matrix


hi, have constructed first matrix 17 neopixels long 8 neopixels. 8 rows of 17 neopixels in zigzag pattern.

i have couple of questions. when run matrixtest code in arduino, "howdy" example being displayed sideways. have set in example this:

code: [select]
// adafruit_neomatrix example single neopixel shield.
// scrolls 'howdy' across matrix in portrait (vertical) orientation.

#include <adafruit_gfx.h>
#include <adafruit_neomatrix.h>
#include <adafruit_neopixel.h>
#ifndef pstr
 #define pstr // make arduino due happy
#endif

#define pin 6

// matrix declaration:
// parameter 1 = width of neopixel matrix
// parameter 2 = height of matrix
// parameter 3 = pin number (most valid)
// parameter 4 = matrix layout flags, add needed:
//   neo_matrix_top, neo_matrix_bottom, neo_matrix_left, neo_matrix_right:
//     position of first led in matrix; pick two, e.g.
//     neo_matrix_top + neo_matrix_left top-left corner.
//   neo_matrix_rows, neo_matrix_columns: leds arranged in horizontal
//     rows or in vertical columns, respectively; pick 1 or other.
//   neo_matrix_progressive, neo_matrix_zigzag: rows/columns proceed
//     in same order, or alternate lines reverse direction; pick one.
//   see example below these values in action.
// parameter 5 = pixel type flags, add needed:
//   neo_khz800  800 khz bitstream (most neopixel products w/ws2812 leds)
//   neo_khz400  400 khz (classic 'v1' (not v2) flora pixels, ws2811 drivers)
//   neo_grb     pixels wired grb bitstream (most neopixel products)
//   neo_rgb     pixels wired rgb bitstream (v1 flora pixels, not v2)


// example neopixel shield.  in application we'd use it
// 5x8 tall matrix, usb port positioned @ top of the
// arduino.  when held way, first pixel @ top right, and
// lines arranged in columns, progressive order.  shield uses
// 800 khz (v2) pixels expect grb color data.
adafruit_neomatrix matrix = adafruit_neomatrix(5, 8, pin,
  neo_matrix_top     + neo_matrix_left +
  neo_matrix_columns + neo_matrix_zigzag,
  neo_grb            + neo_khz800);

const uint16_t colors[] = {
  matrix.color(255, 0, 0), matrix.color(0, 255, 0), matrix.color(0, 0, 255) };

void setup() {
  matrix.begin();
  matrix.settextwrap(false);
  matrix.setbrightness(40);
  matrix.settextcolor(colors[0]);
}

int x    = matrix.width();
int pass = 0;

void loop() {
  matrix.fillscreen(0);
  matrix.setcursor(x, 0);
  matrix.print(f("howdy"));
  if(--x < -36) {
    x = matrix.width();
    if(++pass >= 3) pass = 0;
    matrix.settextcolor(colors[pass]);
  }
  matrix.show();
  delay(100);
}

if flip matrix way makes long tall without howdy being utilized. i've tried rearranging columns , top/bottom right/left etc. , if change these won't display howdy correctly. anyway can around displays way want instead of 90 degrees right?

here schematic on how have setup arranged, 0 neopixel leading arduino uno, (so starts in top right)
code: [select]

  {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,0},
  {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33},
  {50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34},
  {51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67},
  {84, 83, 82, 81, 80, 79, 78, 77, 76, 76, 74, 73, 72, 71, 70, 69, 68},
  {85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101},
  {118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102},
  {119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135}


question #2, have made word "sam" on matrix using simple set pixels, approach noob coder shift right efficiently until off screen or in loop? way know create "sam" in multiple versions on matrix each version shifted 1 pixel right , display each 1 after delay in between. don't know how correctly in multidimensional array think done in. here source code have creating "sam" in matrix.
code: [select]

#include <adafruit_neopixel.h>
#define pin 6
#define n_leds 135

adafruit_neopixel strip = adafruit_neopixel(n_leds, pin, neo_grb + neo_khz800);

void setup() {
  strip.begin();
  strip.show();
}
void loop() {
  strip.setpixelcolor(16, 255, 0, 0);
  strip.setpixelcolor(15, 255, 0, 0);
  strip.setpixelcolor(14, 255, 0, 0);
  strip.setpixelcolor(17, 255, 0, 0);
  strip.setpixelcolor(50, 255, 0, 0);
  strip.setpixelcolor(49, 255, 0, 0);
  strip.setpixelcolor(48, 255, 0, 0);
  strip.setpixelcolor(53, 255, 0, 0);
  strip.setpixelcolor(84, 255, 0, 0);
  strip.setpixelcolor(83, 255, 0, 0);
  strip.setpixelcolor(82, 255, 0, 0);
  strip.setpixelcolor(79, 255, 0, 255);
  strip.setpixelcolor(56, 255, 0, 255);
  strip.setpixelcolor(45, 255, 0, 255);
  strip.setpixelcolor(44, 255, 0, 255); 
  strip.setpixelcolor(43, 255, 0, 255);
  strip.setpixelcolor(22, 255, 0, 255);
  strip.setpixelcolor(11, 255, 0, 255);
  strip.setpixelcolor(10, 255, 0, 255);
  strip.setpixelcolor(9, 255, 0, 255);
  strip.setpixelcolor(24, 255, 0, 255);
  strip.setpixelcolor(58, 255, 0, 255);
  strip.setpixelcolor(77, 255, 0, 255);
  strip.setpixelcolor(74, 0, 255, 0);
  strip.setpixelcolor(61, 0, 255, 0);
  strip.setpixelcolor(40, 0, 255, 0);
  strip.setpixelcolor(27, 0, 255, 0);
  strip.setpixelcolor(6, 0, 255, 0);
  strip.setpixelcolor(28, 0, 255, 0);
  strip.setpixelcolor(38, 0, 255, 0);
  strip.setpixelcolor(30, 0, 255, 0);
  strip.setpixelcolor(2, 0, 255, 0);
  strip.setpixelcolor(31, 0, 255, 0);
  strip.setpixelcolor(36, 0, 255, 0);
  strip.setpixelcolor(65, 0, 255, 0);
  strip.setpixelcolor(70, 0, 255, 0);
  strip.show();
}


question 3, trying wrap head around using 2d array i'm having trouble , clarification on i'm doing other sketch code trying since know doesn't work. think have initialized matrix in new sketch array created array turning on pixels declared should "sam" again. don't know how set colors in array color , how call function correctly. trying efficient , wanted create couple functions have words way feel it'd more efficient telling each pixel light call them delays in each call. guys recommend , how supposed right way don't know go here. thank guys much!
code: [select]
#include <adafruit_neopixel.h>
#define pin 6
#define n_leds 135

adafruit_neopixel strip = adafruit_neopixel(n_leds, pin, neo_grb + neo_khz800);

int matrix[8][17] = {
  {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,0},
  {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33},
  {50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34},
  {51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67},
  {84, 83, 82, 81, 80, 79, 78, 77, 76, 76, 74, 73, 72, 71, 70, 69, 68},
  {85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101},
  {118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102},
  {119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135}
  }
}

byte sam(){
 {1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0 ,0},
 {1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0},
 {1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0},
 {0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0},
 {1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 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, 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}
 
 
}


void setup() {
  strip.begin();
  strip.show();
}
void loop() {
  strip.sam();
  strip.show();
}-

quote
neopixels in zigzag pattern.
that called serpentine raster.

there 2 ways of making matrix this, 1 strips on columns, other strip on rows. column matrix.


now way drive write function translate x , y coordinates led number.

led number = y + (x * number of leds in column)
however odd numbered columns conversion :-
led number = (x * number of leds in column) + (number of leds in column -1 -y)
to determine if x coordinate odd or even, @ least significant bit of x value , if 0 column or if 1 odd column. software has examine x - coordinate , decide formula use. simple enough make function returns led number given x & y values.

code: [select]

int getledpos(int x, int y){ // serpentine raster
   int pos;
   if(x & 0x1) { // x odd
      pos = x * ymax + (ymax -1 - y) ;
   } else { // x even
      pos = x * ymax + y;
 }
    return pos;
}


where ymax number of leds in column.

then can treat matrix 2 dimensional display. of course if have row serpentine matrix or wire matrix backwards, right left, have reflect in above function.

now scroll transfer matrix defining display want 1 column offset led buffer. shifts whole pattern on right or left depending on sign of offset.


Arduino Forum > Using Arduino > LEDs and Multiplexing > Help with 8x17 LED Neopixel Matrix


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'