user31414: first of all I'm sorry for my english.
My problem is that I want to use an array of numbers on a function, but I'm getting a weird result inside a for loop. Doing some tests I've seen that it happens even in the simplest sketch so I should be doing something wrong.
I've created a two level int and I want to iterate through the second level using a for loop. Outside the for loop all data gotten from that array is OK, but just inside the loop I'm just getting garbage as if the array was not initialized.
My simple sketch is this:
const int number_small[][14] PROGMEM = {
  {124, 124, 387, 387, 399, 399, 443, 443, 483, 483, 387, 387, 124, 124},
};

void setup() {
  Serial.begin(9600);


  Serial.print(String(number_small[0][0]) + "\n");
  Serial.print(String(number_small[0][1]) + "\n");
  Serial.print(String(number_small[0][2]) + "\n");
  Serial.print(String(number_small[0][3]) + "\n");
  Serial.print(String(number_small[0][4]) + "\n");
  Serial.print(String(number_small[0][5]) + "\n");
  Serial.print(String(number_small[0][6]) + "\n");
  Serial.print(String(number_small[0][7]) + "\n");
  Serial.print(String(number_small[0][8]) + "\n");
  Serial.print(String(number_small[0][9]) + "\n");
  Serial.print(String(number_small[0][10]) + "\n");
  Serial.print(String(number_small[0][11]) + "\n");
  Serial.print(String(number_small[0][12]) + "\n");
  Serial.print(String(number_small[0][13]) + "\n\n\n");

  for (int i = 0; i<14; i++){
    Serial.print("I: " + String(i) + " - " + String(number_small[0][i]) + "\n");
  }
}

void loop() {
}

And the output is:
124
124
387
387
399
399
443
443
483
483
387
387
124
124

I: 0 - 0
I: 1 - 184
I: 2 - 0
I: 3 - 1
I: 4 - 0
I: 5 - -18248
I: 6 - -18248
I: 7 - -18248
I: 8 - 0
I: 9 - 135
I: 10 - 0
I: 11 - 0
I: 12 - 769
I: 13 - 0

What I'm doing wrong?,
Thanks!!

user31414: I was sure that I was doing something wrong and yes... Finally I did another test (storing the array on SRAM instead on PROGMEM) and it worked, so I've changed my "research direction" and I've found the solution.
With my initial sketch I was reading the PROGMEM from outside the loop, but from inside the loop what i read is the SDRAM, so I've to use the pgm_read functions to force to read from PROGMEM, and now finally is working:

pgm_read_word(number_small[0] + i)

const int number_small[][14] PROGMEM = {
  {124, 124, 387, 387, 399, 399, 443, 443, 483, 483, 387, 387, 124, 124},
};

void setup() {
  Serial.begin(9600);


  Serial.print(String(number_small[0][0]) + "\n");
  Serial.print(String(number_small[0][1]) + "\n");
  Serial.print(String(number_small[0][2]) + "\n");
  Serial.print(String(number_small[0][3]) + "\n");
  Serial.print(String(number_small[0][4]) + "\n");
  Serial.print(String(number_small[0][5]) + "\n");
  Serial.print(String(number_small[0][6]) + "\n");
  Serial.print(String(number_small[0][7]) + "\n");
  Serial.print(String(number_small[0][8]) + "\n");
  Serial.print(String(number_small[0][9]) + "\n");
  Serial.print(String(number_small[0][10]) + "\n");
  Serial.print(String(number_small[0][11]) + "\n");
  Serial.print(String(number_small[0][12]) + "\n");
  Serial.print(String(number_small[0][13]) + "\n\n\n");

  int i;
  for (i = 0; i<14; i++){
    Serial.print("I: " + String(i) + " - " + String(pgm_read_word(number_small[0] + i)) + "\n");
  }
}

void loop() {
}

Thanks and greetings!!

user-1: I refined your own answer:

No need to use String to print a numeric value; just print the value.
No need to add "\n" add the end of print, use printlninstead.
No need to concatenate strings for printing; just print them one by one.
In a for loop, declare the control variable inside

Code
const int ITEMS = 14;
const int number_small[][ITEMS] PROGMEM = {
  {124, 124, 387, 387, 399, 399, 443, 443, 483, 483, 387, 387, 124, 124},
};

void setup() {
  Serial.begin(9600);

  for (int i=0; i < ITEMS; i++) {
    Serial.println(pgm_read_word(number_small[0]+i));
  }
  Serial.println();  Serial.println();
  for (int i = 0; i < ITEMS; i++){
    Serial.print("I: "); Serial.print(i); Serial.print(" - " );
    Serial.println(pgm_read_word(number_small[0] + i));
  }
}

void loop() {
}


user23841: Constants like String(number_small[0][0]) are optimized by compiler during the build (=compile time).
However that's not the case of loop. So you have to use specific functions for reading values from PROGMEM in the runtime:
for (int i = 0; i<14; i++){
  Serial.print("I: ");
  Serial.print(i);
  Serial.print(" - ");
  Serial.println((int)pgm_read_word(number_small[0]+i));
}

Btw: Don't use string concatenations. These are extremely hungry for the memory. See Majenko's article: The Evils of Arduino Strings

31414: <p>first of all I'm sorry for my english.</p>

<p>My problem is that I want to use an array of numbers on a function, but I'm getting a weird result inside a for loop. Doing some tests I've seen that it happens even in the simplest sketch so I should be doing something wrong.</p>

<p>I've created a two level int and I want to iterate through the second level using a for loop. Outside the for loop all data gotten from that array is OK, but just inside the loop I'm just getting garbage as if the array was not initialized.</p>

<p>My simple sketch is this:</p>

<pre><code>const int number_small[][14] PROGMEM = {
  {124, 124, 387, 387, 399, 399, 443, 443, 483, 483, 387, 387, 124, 124},
};

void setup() {
  Serial.begin(9600);


  Serial.print(String(number_small[0][0]) + "\n");
  Serial.print(String(number_small[0][1]) + "\n");
  Serial.print(String(number_small[0][2]) + "\n");
  Serial.print(String(number_small[0][3]) + "\n");
  Serial.print(String(number_small[0][4]) + "\n");
  Serial.print(String(number_small[0][5]) + "\n");
  Serial.print(String(number_small[0][6]) + "\n");
  Serial.print(String(number_small[0][7]) + "\n");
  Serial.print(String(number_small[0][8]) + "\n");
  Serial.print(String(number_small[0][9]) + "\n");
  Serial.print(String(number_small[0][10]) + "\n");
  Serial.print(String(number_small[0][11]) + "\n");
  Serial.print(String(number_small[0][12]) + "\n");
  Serial.print(String(number_small[0][13]) + "\n\n\n");

  for (int i = 0; i&lt;14; i++){
    Serial.print("I: " + String(i) + " - " + String(number_small[0][i]) + "\n");
  }
}

void loop() {
}
</code></pre>

<p>And the output is:</p>

<pre><code>124
124
387
387
399
399
443
443
483
483
387
387
124
124

I: 0 - 0
I: 1 - 184
I: 2 - 0
I: 3 - 1
I: 4 - 0
I: 5 - -18248
I: 6 - -18248
I: 7 - -18248
I: 8 - 0
I: 9 - 135
I: 10 - 0
I: 11 - 0
I: 12 - 769
I: 13 - 0
</code></pre>

<p>What I'm doing wrong?,</p>

<p>Thanks!!</p>
 31414: <p>I was sure that I was doing something wrong and yes... Finally I did another test (storing the array on SRAM instead on PROGMEM) and it worked, so I've changed my "research direction" and I've found the solution.</p>

<p>With my initial sketch I was reading the PROGMEM from outside the loop, but from inside the loop what i read is the SDRAM, so I've to use the <strong>pgm_read</strong> functions to force to read from PROGMEM, and now finally is working:</p>

<blockquote>
  <p>pgm_read_word(number_small[0] + i)</p>
</blockquote>

<pre><code>const int number_small[][14] PROGMEM = {
  {124, 124, 387, 387, 399, 399, 443, 443, 483, 483, 387, 387, 124, 124},
};

void setup() {
  Serial.begin(9600);


  Serial.print(String(number_small[0][0]) + "\n");
  Serial.print(String(number_small[0][1]) + "\n");
  Serial.print(String(number_small[0][2]) + "\n");
  Serial.print(String(number_small[0][3]) + "\n");
  Serial.print(String(number_small[0][4]) + "\n");
  Serial.print(String(number_small[0][5]) + "\n");
  Serial.print(String(number_small[0][6]) + "\n");
  Serial.print(String(number_small[0][7]) + "\n");
  Serial.print(String(number_small[0][8]) + "\n");
  Serial.print(String(number_small[0][9]) + "\n");
  Serial.print(String(number_small[0][10]) + "\n");
  Serial.print(String(number_small[0][11]) + "\n");
  Serial.print(String(number_small[0][12]) + "\n");
  Serial.print(String(number_small[0][13]) + "\n\n\n");

  int i;
  for (i = 0; i&lt;14; i++){
    Serial.print("I: " + String(i) + " - " + String(pgm_read_word(number_small[0] + i)) + "\n");
  }
}

void loop() {
}
</code></pre>

<p>Thanks and greetings!!</p>
 -1: <p>I refined your own answer:</p>

<ul>
<li>No need to use String to print a numeric value; just print the value.</li>
<li>No need to add "\n" add the end of <code>print</code>, use <code>println</code>instead.</li>
<li>No need to concatenate strings for printing; just print them one by one.</li>
<li>In a <code>for</code> loop, declare the control variable <em>inside</em></li>
</ul>

<p>Code</p>

<pre><code>const int ITEMS = 14;
const int number_small[][ITEMS] PROGMEM = {
  {124, 124, 387, 387, 399, 399, 443, 443, 483, 483, 387, 387, 124, 124},
};

void setup() {
  Serial.begin(9600);

  for (int i=0; i &lt; ITEMS; i++) {
    Serial.println(pgm_read_word(number_small[0]+i));
  }
  Serial.println();  Serial.println();
  for (int i = 0; i &lt; ITEMS; i++){
    Serial.print("I: "); Serial.print(i); Serial.print(" - " );
    Serial.println(pgm_read_word(number_small[0] + i));
  }
}

void loop() {
}
</code></pre>
 23841: <p>Constants like <code>String(number_small[0][0])</code> are optimized by compiler during the build (=compile time).</p>

<p>However that's not the case of loop. So you have to use specific functions for reading values from <code>PROGMEM</code> in the runtime:</p>

<pre><code>for (int i = 0; i&lt;14; i++){
  Serial.print("I: ");
  Serial.print(i);
  Serial.print(" - ");
  Serial.println((int)pgm_read_word(number_small[0]+i));
}
</code></pre>

<p>Btw: Don't use string concatenations. These are extremely hungry for the memory. See Majenko's article: <a href="https://hackingmajenkoblog.wordpress.com/2016/02/04/the-evils-of-arduino-strings/" rel="nofollow noreferrer">The Evils of Arduino Strings</a></p>
