One of my hobbies is getting into Arduino programming projects that are way over my head. I have built an art machine involving 3 stepper motors, 3 servos, and even a color detector, and I have each of those operating as I had hoped (many error messages later.) I am a decent, not expert Arduino c++ programmer.
Now I am trying to convert individual letters of the alphabet into 25 character char strings that, broken into groups of fives and stacked, will allow me to represent each letter in white and red marbles in a 5 X 5 grid.
I have been messing around with formatting brackets, parentheses, this and that and chasing error messages on this forum for so long that even shy me finally breaks down and asks for help.
My current error message, one of several, is:
/Users/gordo/String_Play/String_Play.ino: In function 'void displayFont(char)':
/Users/gordo/String_Play/String_Play.ino:28:17: error: invalid array assignment
tempstr = "rwwwrrrrrrwrwrwwrwrwwwrww";
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/gordo/String_Play/String_Play.ino:31:17: error: invalid array assignment
tempstr = "wwrrrwrwwrwwrrrwrwwrwwrrr";
^~~~~~~~~~~~~~~~~~~~~~~~~~~
etc. for each subsequent line
My code as it currently stands, called by ā displayFont(alphatext[i]);ā in Loop()
void displayFont(char letter){ //letter is single lower case letter
char tempstr[26]; //create string 26 characters long
switch(letter){ // depending on letter
case 'a': //if it is "a"
tempstr = "rwwwrrrrrrwrwrwwrwrwwwrww"; //Assign this string ERROR!
break; // if it wasn't "a"
case 'b': // try "b" etc.
tempstr = "wwrrrwrwwrwwrrrwrwwrwwrrr";
break;
case 'c':
tempstr = "wrrrwwwwwrwwwwrrwwwrwrrrw";
break;
case 'd':
tempstr = "wwrrrwrwwrwrwwrwrwwrwwrrr";
break;
case 'e':
tempstr = "wrrrrwwwwrwwrrrwwwwrwrrrr";
break;
case 'f':
tempstr = "wwwwrwwwwrwwrrrwwwwrwrrrr";
break;
case 'g':
tempstr = "wrrrwwrwwrwrrwrwwwwrwrrrw";
break;
case 'h':
tempstr = "wrwwrwrwwrwrrrrwrwwrwrwwr";
break;
}
for (int ii = 0; ii < 25; ii = ii + 5){ // this part is included for your
// amusement. I haven't gotten past
for (int jj = 0; jj < 5; jj++){ // the part above so I haven't
char tempLetter = tempstr[ii + jj]; // tested this yet.
if (tempLetter == 'w'){
Serial.print (" ");//Eventually: Feed a white marble to the tray
}
else if (tempLetter == "r"){
Serial.print("*"); //Feed a red marble to the tray
}
Serial.println(); //dump the tray in the 5 X 5 display
}
} // and using the serial monitor the letters will appear
} // upside down. The marbles will stack bottom to top.
Program runs on an Arduino Mega, Iām using Arduino IDE 2.3.6