The code below was working for me in
0012 0011 (see update below), but it seems to crash the AVR / return to the bootloader on the strcpy_P() line when uploaded to a stock diecimila.
/*
*PROGMEM test
*/
#include <avr/pgmspace.h>
char string_1[] PROGMEM = "String 1";
char string_2[] PROGMEM = "String 2";
char string_3[] PROGMEM = "String 3";
char string_4[] PROGMEM = "String 4";
char string_5[] PROGMEM = "String 5";
PGM_P PROGMEM string_table[] =
{
string_1,
string_2,
string_3,
string_4,
string_5
};
void setup()
{
Serial.begin(9600);
}
char buffer[10];
void loop() // run over and over again
{
for (unsigned char i = 0; i < 5; i++)
{
strcpy_P(buffer, (char * )pgm_read_word(&(string_table[i])));
Serial.println( buffer );
delay( 500 );
}
}
update: code worked in 0011, not 0012