I am trying out Arduino programming for the first time and am having issues with an array that causes two undesirable behaviors depending on the position of said array in the code. The array must be used in a function called ''writeMenuChoicePokemon'' in order to change random integers into random strings with the names of the available monsters.
My first attempt was to put
String array_names[21] =
{
"Bulbasaur","Charmander","Squirtle","Ekans","Pikachu","Jigglypuff","Zubat","Venonat","Meowth","Psyduck","Mankey","Abra",
"Tentacool","Geodude","Magnemite","Gastly","Onix","Hitmonlee","Rhyhorn","Jynx","Dragonite"
};
into the function itself and use for example
lcd.print(array_names[pokemon1])
with pokemon1 being a random integer, but when the random ints are between 14 and 20 the result is an empty string. What can be causing this?
My second attempt was to put array_names as a global variable, but my program stops responding to my button inputs and doesn't show anything at all on the screen except for the random Pokémon. Could this be due to lack of memory? Where is the proper position to declare an array used in the main loop?
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire