Skip to main content
added 34 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50
const byte a1[] PROGMEM = {'a', 'b', 'c', 'd'};
const byte a2[] PROGMEM = {'e', 'f', 'g', 'h', 'i'};
const byte a3[] PROGMEM = {'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'};
const byte a4[] PROGMEM = {'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

const byte * const arr[] PROGMEM = {a1, a2, a3, a4};

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

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      Serial.print('[');
      Serial.print(i);
      Serial.print(',:');
     for Serial.print(int j);
 = 0; j < 4; Serial.print("]:"j++); {
      Serial.printlnprint((char) pgm_read_byte_near(pgm_read_word(arr + i) + j));
      Serial.print(',');
    }
    Serial.println();
  }
}

void loop() {

}

output

0:a,b,c,d,
1:e,f,g,h,
2:j,k,l,m,
3:r,s,t,u,

at runtime the size of the arrays is unknown, so I print the first 4 items

const byte a1[] PROGMEM = {'a', 'b', 'c', 'd'};
const byte a2[] PROGMEM = {'e', 'f', 'g', 'h', 'i'};
const byte a3[] PROGMEM = {'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'};
const byte a4[] PROGMEM = {'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

const byte * const arr[] PROGMEM = {a1, a2, a3, a4};

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

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      Serial.print('[');
      Serial.print(i);
      Serial.print(',');
      Serial.print(j);
      Serial.print("]:");
      Serial.println((char) pgm_read_byte_near(pgm_read_word(arr + i) + j));
    }
  }
}

void loop() {

}
const byte a1[] PROGMEM = {'a', 'b', 'c', 'd'};
const byte a2[] PROGMEM = {'e', 'f', 'g', 'h', 'i'};
const byte a3[] PROGMEM = {'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'};
const byte a4[] PROGMEM = {'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

const byte * const arr[] PROGMEM = {a1, a2, a3, a4};

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

  for (int i = 0; i < 4; i++) {
    Serial.print(i);
    Serial.print(':');
    for (int j = 0; j < 4; j++) {
      Serial.print((char) pgm_read_byte_near(pgm_read_word(arr + i) + j));
      Serial.print(',');
    }
    Serial.println();
  }
}

void loop() {

}

output

0:a,b,c,d,
1:e,f,g,h,
2:j,k,l,m,
3:r,s,t,u,

at runtime the size of the arrays is unknown, so I print the first 4 items

Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

const byte a1[] PROGMEM = {'a', 'b', 'c', 'd'};
const byte a2[] PROGMEM = {'e', 'f', 'g', 'h', 'i'};
const byte a3[] PROGMEM = {'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'};
const byte a4[] PROGMEM = {'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

const byte * const arr[] PROGMEM = {a1, a2, a3, a4};

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

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      Serial.print('[');
      Serial.print(i);
      Serial.print(',');
      Serial.print(j);
      Serial.print("]:");
      Serial.println((char) pgm_read_byte_near(pgm_read_word(arr + i) + j));
    }
  }
}

void loop() {

}