as int*. The error message says that it can't convert a pointer to int into a pointer to char in the first argument to strcpy(). That suggests that buffer should be declared as char* in order to use it in strcpy.
Changing the decaration of buffer won't fix everything, but it's a start. You might be able to take it from there.
You'll also want to look at the way you declare the stringX[] array constants. Keep in mind that a C string is terminated by a zero byte. Where would that byte be stored in these array constants?
/Users/john/Documents/Arduino/sketch_may09a/sketch_may09a.ino: In function 'void loop()':
sketch_may09a:25: error: cannot convert 'int*' to 'char*' for argument '1' to 'char* strcpy_P(char*, const char*)'
strcpy_P(buffer, (int*)pgm_read_word(&(string_table[i])));
This error means you are trying to use the address of an int array as if it were a character pointer. You seem to be very confused.
sketch_may09a:26: error: call of overloaded 'println(int [30])' is ambiguous
Serial.println(buffer);
^
This error means that you can't pass an array of 30 integers to .print() or .println(*). What did you want to do with those integers? Print the values of all 30 integers on separate lines???
If you want to put integers in PROGMEM you would do it more like:
const int integer_table[] PROGMEM = {1, 2, 3, 4, 5, 6};
void setup() {
Serial.begin(9600);
}
void loop() {
for (int i = 0; i < sizeof integer_table / sizeof integer_table[0]; i++) {
Serial.println(pgm_read_word(&integer_table[i]));
delay(500);
}
}
The first argument is buffer. It's declared like this: const int* const string_table[] PROGMEM={string0,string1,string2,string3,string4,string5};
as int*. The error message says that it can't convert a pointer to int into a pointer to char in the first argument to strcpy(). That suggests that buffer should be declared as char* in order to use it in strcpy. Changing the decaration of buffer won't fix everything, but it's a start. You might be able to take it from there. You'll also want to look at the way you declare the stringX[] array constants. Keep in mind that a C string is terminated by a zero byte. Where would that byte be stored in these array constants?
It seems that I'm still confused with the pointer I tried to do as in this example but instead of printing char I wanted to print integers but didnt work.
const char string_0[] PROGMEM = "String 0"; // "String 0" etc are strings to store - change to suit.
const char string_1[] PROGMEM = "String 1";
const char string_2[] PROGMEM = "String 2";
const char string_3[] PROGMEM = "String 3";
const char string_4[] PROGMEM = "String 4";
const char string_5[] PROGMEM = "String 5";
// Then set up a table to refer to your strings.
const char* const string_table[] PROGMEM = {string_0, string_1, string_2, string_3, string_4, string_5};
char buffer[30]; // make sure this is large enough for the largest string it must hold
void setup()
{
Serial.begin(9600);
while(!Serial);
Serial.println("OK");
}
void loop()
{
/* Using the string table in program memory requires the use of special functions to retrieve the data.
The strcpy_P function copies a string from program space to a string in RAM ("buffer").
Make sure your receiving string in RAM is large enough to hold whatever
you are retrieving from program space. */
for (int i = 0; i < 6; i++)
{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i]))); // Necessary casts and dereferencing, just copy.
Serial.println(buffer);
delay( 500 );
}
}
[code]
[/code]
I declared buffer as char but still have no clue what to do next ^^'
This error means that you can't pass an array of 30 integers to .print() or .println(*). What did you want to do with those integers? Print the values of all 30 integers on separate lines???
Yes, That is what I wanted to do but using the method in this example
void loop()
{
/* Using the string table in program memory requires the use of special functions to retrieve the data.
The strcpy_P function copies a string from program space to a string in RAM ("buffer").
Make sure your receiving string in RAM is large enough to hold whatever
you are retrieving from program space. */
for (int i = 0; i < 6; i++)
{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table*))); // Necessary casts and dereferencing, just copy.*