// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#define PIN 6 // connected pin on the Arduino
#define NUMPIXELS 16 // Number of NeoPixels
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
char two[] = {1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1};
char three[] = {1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1};
char choose=two;
void setup()
{
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop()
{
pixels.clear(); // Set all pixel colors to 'off'
// The first NeoPixel in a strand is #0, second is 1, all the way up
// to the count of pixels minus one.
for(int i=0; i<NUMPIXELS; i++)
{ // For each pixel...
// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// Here we're using a moderately bright green color:
//if (two[i] == 1)
if (choose[i] == 1)
{
pixels.setPixelColor(i, pixels.Color(0, 150, 0));
}
else
{
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
}
}
//pixels.setPixelColor(i, pixels.Color(0, 150, 0));
pixels.show(); // Send the updated pixel colors to the hardware.
delay(1000); // Pause before next pass through loop
if (choose == two)
choose=three;
else
choose=two;
//}
}
I am at the early stage of programming a neopixel to give me a choice of numbers (and colours) but I am stuck with the correct protocol.
If I make the first 'if' statement
if (choose[i] == 1)
trying to get it to choose between array two or three I get
'Compilation error: invalid types 'char[int]' for array subscript'
If I comment it out and uncomment out the line above
if (two[i] == 1)
so I just get array two
the compile works?
What do I need to use to make the sketch allow me to choose the array I want?