Help with old POV (persistence of vision) code

Hi Guys!

A few years ago I did a simple POV (persistence of vision) project (see attached picture), I'd found code online which worked very well at the time and I would like to use it again, however when I upload it now it gives the error message shown below. I think it has to do with updated Arduino code but I can't figure out how to fix it.

Some help would be very much appreciated!


Arduino: 1.8.7 (Mac OS X), Board: "Arduino/Genuino Uno"

In file included from /Users/davehagen/Downloads/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:28:0,
from sketch/sketch_nov04a.ino.cpp:1:
sketch_nov04a:54:19: error: variable 'letterA' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterA[] PROGMEM = {
^
sketch_nov04a:77:19: error: variable 'letterB' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterB[] PROGMEM = {
^
sketch_nov04a:100:19: error: variable 'letterC' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterC[] PROGMEM = {
^
sketch_nov04a:123:19: error: variable 'letterD' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterD[] PROGMEM = {
^
sketch_nov04a:146:19: error: variable 'letterE' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterE[] PROGMEM = {
^
sketch_nov04a:169:19: error: variable 'letterF' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterF[] PROGMEM = {
^
sketch_nov04a:192:19: error: variable 'letterG' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterG[] PROGMEM = {
^
sketch_nov04a:215:19: error: variable 'letterH' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterH[] PROGMEM = {
^
sketch_nov04a:238:19: error: variable 'letterI' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterI[] PROGMEM = {
^
sketch_nov04a:261:19: error: variable 'letterJ' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterJ[] PROGMEM = {
^
sketch_nov04a:284:19: error: variable 'letterK' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterK[] PROGMEM = {
^
sketch_nov04a:307:19: error: variable 'letterL' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterL[] PROGMEM = {
^
sketch_nov04a:330:19: error: variable 'letterM' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterM[] PROGMEM = {
^
sketch_nov04a:353:19: error: variable 'letterN' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterN[] PROGMEM = {
^
sketch_nov04a:376:19: error: variable 'letterO' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterO[] PROGMEM = {
^
sketch_nov04a:399:19: error: variable 'letterP' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterP[] PROGMEM = {
^
sketch_nov04a:422:19: error: variable 'letterQ' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterQ[] PROGMEM = {
^
sketch_nov04a:445:19: error: variable 'letterR' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterR[] PROGMEM = {
^
sketch_nov04a:468:19: error: variable 'letterS' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterS[] PROGMEM = {
^
sketch_nov04a:491:19: error: variable 'letterT' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterT[] PROGMEM = {
^
sketch_nov04a:514:19: error: variable 'letterU' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterU[] PROGMEM = {
^
sketch_nov04a:537:19: error: variable 'letterV' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterV[] PROGMEM = {
^
sketch_nov04a:560:19: error: variable 'letterW' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterW[] PROGMEM = {
^
sketch_nov04a:583:19: error: variable 'letterX' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterX[] PROGMEM = {
^
sketch_nov04a:606:19: error: variable 'letterY' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterY[] PROGMEM = {
^
sketch_nov04a:629:19: error: variable 'letterZ' must be const in order to be put into read-only section by means of 'attribute((progmem))'
boolean letterZ[] PROGMEM = {
^
exit status 1
variable 'letterA' must be const in order to be put into read-only section by means of 'attribute((progmem))'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Have you tried making the booleans const?

Yes it does, but unfortunately I don't know how to do that. Can someone show me where I can find how to do this?

Thanks for your quick responses!

It's just an additional keyword when you declare the variable, like this:

const boolean letterA[] PROGMEM = { ... etc }

You'll have to do that for all 26 of the boolean arrays in the error message.

I know, I didn't send the complete code, just the error message. It seems to work better already because I can upload it en the LED's start to work but still I get some sort of error.

I've attached the complete code now.

This is the current error:

/Users/davehagen/Dropbox/Dave/Rietveld/2015:16/Semester 1/Inter(re)action/POV_sketch_aangepast/POV_sketch_aangepast.ino: In function 'void loop()':
/Users/davehagen/Dropbox/Dave/Rietveld/2015:16/Semester 1/Inter(re)action/POV_sketch_aangepast/POV_sketch_aangepast.ino:1312:25: warning: invalid conversion from 'const boolean* {aka const bool*}' to 'boolean* {aka bool*}' [-fpermissive]
sendToWand(letterA);
^
/Users/davehagen/Dropbox/Dave/Rietveld/2015:16/Semester 1/Inter(re)action/POV_sketch_aangepast/POV_sketch_aangepast.ino:1097:8: note: initializing argument 1 of 'void sendToWand(boolean*)'
void sendToWand(boolean letterArray[]){//function to get array data
^
/Users/davehagen/Dropbox/Dave/Rietveld/2015:16/Semester 1/Inter(re)action/POV_sketch_aangepast/POV_sketch_aangepast.ino:1315:25: warning: invalid conversion from 'const boolean* {aka const bool*}' to 'boolean* {aka bool*}' [-fpermissive]
sendToWand(letterB);
^

POV_sketch_aangepast.ino (47 KB)

Lol! You are completely right, no error to be seen.

So if I understand correctly I can ignore this warning?

Yes the code does what I want! Thanks for your help.

You can ignore the warnings this time, but in the future you might get a warning that means your code won't work. It's best to try to fix them.

In this case the fix is easy. In your "sendToWand()" function, just add the 'const' keyword to the declaration of the function argument. That tells the compiler that it is safe to pass a pointer to a 'const' array because the function promises not to write into the array. It also allows the compiler to enforce that promise by generating an error if code in your function writes into the const data.