and in a different tab/file I try to add an extern statement, something like:
extern const byte someVariable[10] PROGMEM;
void someFunction(void)
{
// Example code just to show where I use this.
someVariable[0] = 4;
...
}
But I get an error when trying to compile the sketch. I have search for a solution, but have not found anything that have helped me solve this problem.
The error I get is
sketch/someFunction.cpp:100: undefined reference to `someVariable'
Not really your question on external, but How do you think the compiler can assign a value to something that is const and in flash memory when you write:
Tabs aren't external. The IDE combines all the files represented by tabs into a single sketch. Globals defined in the main (first) tab are in scope for all other tabs.
SteveMann:
Tabs aren't external. The IDE combines all the files represented by tabs into a single sketch. Globals defined in the main (first) tab are in scope for all other tabs.
You're talking about using the Arduino-recommended practice of multiple .ino files / tabs. IMO, that's useless. If you use you proper .cpp and .h files / tabs then you can have meaningful code modularity.
TheMemberFormerlyKnownAsAWOL:
The data is in PROGMEM; you can't read it like that.
If it is in PROGMEM, how should it be (read)?
Since the arrays are rather small, I have dropped the PROGMEM, but it would be nice to know how this can be done if I have larger arrays I want/must have in PROGMEM.
thehardwareman:
If it is in PROGMEM, how should it be (read)?
Since the arrays are rather small, I have dropped the PROGMEM, but it would be nice to know how this can be done if I have larger arrays I want/must have in PROGMEM.
The way @gfvalvo did it.
Check the PROGMEM reference page.