Storing 256 strings in Progmen

If each string is 30char, will it fit?

Char == 1 byte So 30 bytes +1 null for each string equals 7936 bytes Ive never tried anything with that memory space but i believe the uuno has 32kb of flash space so you should have enough assuming the bootloader plus your program fits in the remaing 24 kb

The math seems to work. Why not just do it?
BTW, if all strings are equal in length, then you can use pointer increment to point to any one of them. If they are all different in length, you can even store the address to every string in PROGMEM too. I have sample code for that in case you want. I think I took it from a tutorial.

Well, worked just fine . I am using the Sparkfun music shield and a 2x20 display to select the current instrument,

If the strings have a lots of similar substrings one can store more by using a [simple] compression scheme. e.g. if the strings are musical notes "C8 C4 D5" etc one could assign a bytevalue to every note and use a lookuptable to build up the string needed.

Can you tell more about the content of the strings you use ?

I am storing the instrument names ie "Reed Organ". I am using a pot connected to A0 to index though them. Turning the pot displays the instrument name on the 2x20 LCD. Pushing the instrument select button selects the entry display.

The long term goal is to connect to an old school organ keyboard.

mstadtler: I am storing the instrument names ie "Reed Organ". I am using a pot connected to A0 to index though them. Turning the pot displays the instrument name on the 2x20 LCD. Pushing the instrument select button selects the entry display.

The long term goal is to connect to an old school organ keyboard.

So basically you want your keyboard to play different instruments with a selection dial and button?

I am using a pot connected to A0 to index though them

Analog signals can be noisy and selecting an instrument this way means you have only few positions for every choice. Better use a rotary encoder for selection...

robtillaart:

I am using a pot connected to A0 to index though them

Analog signals can be noisy and selecting an instrument this way means you have only few positions for every choice. Better use a rotary encoder for selection...

I was thinking about suggesting the rotary encoder but you have the right reason for it :)

Once made a selection with a potmeter that ignored the noise with the following code (sort of).

int selection;

void setup()
{
  ...
  selection = readUntilStable(1, 2);
  ...
}

void loop()
{
  int x = analogRead(1);  // turn the potmeter back to 0 to indicate a new reading for selection  may be made.
  if (x == 0)
  {
    selection = readUntilStable(1, 2);  // when stable (2 is the noise factor) this function stops.
  }
  // use selection map(selection, 0, 1024, 0, 255);
  ...
}

// warning: this function can block!!
int readUntilStable(int pin, unsigned int delta)
{
  bool stable = false;
  int v=0;
  int w=0;
  do
  {
    v = analogRead(pin);
    delay(50);
    w = analogRead(pin);
    stable = (abs(v-w) < delta);
  } while (!stable);
  return analogRead(pin);
}

Works reasonably well, but never tried above ~50 distinct values. (selection/20)

thanks for the code . It works great!

thanks for the code . It works great!