0

I'm trying to declare a 2-D array where each letter in the alphabet is keyed to a corresponding LED in my LED strip. But when I try to declare the array, Arduino flags the values and gives me a "not declared in this scope" error. I have no idea why. Am I missing a library or is it incorrect syntax?

Some of the places I've looked say to make sure it's declared globally. I've declared the array before void setup but it still doesn't work. Here's what I've got before void setup:

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as 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 are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(50, PIN, NEO_GRB + NEO_KHZ800);

//Create a 2-D array to store each letter and 
//its corresponding LED number
char charKey[26][2]={
  {a, 0},
  {b, 2},
  {c, 4},
  {d, 6},
  {e, 8},
  {f, 20},
  {g, 18},
  {h, 16},
  {i, 14},
  {j, 12},
  {k, 10},
  {l, 22},
  {m, 24},
  {n, 26},
  {o, 28},
  {p, 30},
  {q, 40},
  {r, 38},
  {s, 36},
  {t, 34},
  {u, 32},
  {v, 42},
  {w, 44},
  {x, 46},
  {y, 48},
  {z, 50}
};
0

Without quotes, a, b, c etc. are just names. You didn't declare any of them, so the compiler complains. Put single quotes around the letters to let the compiler know that they are char literals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.