Hi I downloaded the library from Giuthub yesterday and I'm having issues using PROGMEM

Hi I downloaded the library from Giuthub yesterday and I’m having issues using PROGMEM with my Arduino Uno.

The code is here: http://pastebin.com/fTyKSXnU

It is part of a much larger sketch but the issue still exists here. The sketch should cycle through turning all the pixels red, blue and green. However if I store pots, the remap array, in PROGMEM it does not function as expected.

If I remove the PROGMEM it works as expected.

Am I making a basic mistake? Probably!

When you move data out of SRAM and into flash (PROGMEM), you can no longer access it with regular array operators like []. Instead, you use pgm_read_byte_near(…) and pgm_read_word_near(…)

See http://playground.arduino.cc/Main/PROGMEM

The Arduino forums have some pretty helpful threads on this topic, too, e.g. http://forum.arduino.cc/index.php?topic=45681.0

As to WHY this is so, it’s because UNLIKE your regular computer in which all memory (RAM, ROM, etc) is all in one big flat address space, the Arduino’s AVR chip has SEPARATE address spaces for SRAM and flash (PROGMEM). That means that address “120” could be SRAM address 120 OR flash address 120 – and the compiler can’t tell which you mean. So normal […] array operations all use SRAM by default, and when you want to look something up from flash, you have to use the pgm_read functions.

Ah thanks! That explains it! Previously I have used the Flash library (http://arduiniana.org/libraries/flash/) which hid all that from me but I couldn’t get it to work which I (wrongly) assumed was something to do with FastLED. On closer inspection it isn’t so I’ll either try to make it work or get my hands dirty!

And just so you know, the name for split code / data address space computer architectures like AVR uses is “Harvard Architecture” http://en.m.wikipedia.org/wiki/Harvard_architecture