Hello peeps.
i am fitting some neopixels into some old shades and this is how they are layed out
0 1 2 3 4 5 6 7 8
9 10 11 * * * 12 13 14
15 16 17 * * * 18 19 20
I want to be able to make is do a scanner pattern on all three rows but taking into account the gap in the middle????
or maybe change the just the colours in the 3x3 matrices???
neopixel strip - arrays???
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: neopixel strip - arrays???
Make an array of pixel addresses. Put in a -1 for missing pixels:
In your scanner loop, you don't write to any pixels with an address of -1. But the timing will stay correct.
Code: Select all
int pixelArray[][] = { {0, 1, 2, 3, 4, 5, 6, 7, 8} ,
{9, 10, 11, -1, -1, -1, 12, 13, 14},
{15, 16, 17, -1, -1, -1, 18, 19, 20},
};
- lejaybo
- Posts: 30
- Joined: Fri Aug 30, 2013 10:08 am
Re: neopixel strip - arrays???
cheers adafruit_support_rick
this is exactly what i needed!!!1
now time for some code crunching
this is exactly what i needed!!!1
now time for some code crunching
- lejaybo
- Posts: 30
- Joined: Fri Aug 30, 2013 10:08 am
Re: neopixel strip - arrays???
Hello people
I need some help please, i'm not sure how to control my array
i can get basic colours and patterens but i want to be able to do left right scans and matrix patterns
i'm currently got it hooked up to a gemma?
any thoughts??
I need some help please, i'm not sure how to control my array
i can get basic colours and patterens but i want to be able to do left right scans and matrix patterns
i'm currently got it hooked up to a gemma?
any thoughts??
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(21, 1, NEO_GRB + NEO_KHZ800);
int pixelArray[3][9] = {{0, 1, 2, 3, 4, 5, 6, 7, 8},
{9, 10, 11, -1, -1, -1, 12, 13, 14},
{15, 16, 17, -1, -1, -1, 18, 19, 20},
};
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
int i=random(21);
int R=random(255);
int G=random(255);
int B=random(255);
strip.setPixelColor(pixelArray, R, G, B);
strip.show();
}
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: neopixel strip - arrays???
You have to index pixel array by row and column.
Here, you're indexing it by pixel number, since you've given i a number between 0 and 20:
That's not right.
Here's a simplified Larson Scanner: Notice how I'm indexing pixelArray to get the actual pixel number
Here, you're indexing it by pixel number, since you've given i a number between 0 and 20:
Code: Select all
strip.setPixelColor(pixelArray[i][i], R, G, B);
Here's a simplified Larson Scanner: Notice how I'm indexing pixelArray to get the actual pixel number
Code: Select all
#include <Adafruit_NeoPixel.h>
#define N_LEDS 21
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
#define ROWS 3
#define COLUMNS 9
int pixelArray[ROWS][COLUMNS] = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8},
{ 9, 10, 11, -1, -1, -1, 12, 13, 14},
{15, 16, 17, -1, -1, -1, 18, 19, 20},
};
void setup() {
strip.begin();
}
int column = 0;
int row;
int dir = 1; //direction of scan - 1 = L to R, -1 = R to L
void loop() {
// setPixelColor() will clip any pixel index of -1 we don't need to watch for that.
for (row = 0; row < ROWS; row++)
{
strip.setPixelColor(pixelArray[row][column], 0xFF0000);
}
strip.show();
delay(30);
//pixel is now lit. "erase" it for the next loop
for (row = 0; row < ROWS; row++)
{
strip.setPixelColor(pixelArray[row][column], 0);
}
// Bounce off ends of strip
column += dir;
if(column < 0) {
column = 0;
dir = -dir;
} else if(column >= COLUMNS) {
column = COLUMNS - 1;
dir = -dir;
}
}
Please be positive and constructive with your questions and comments.