Let's say I have an array like this:
int x[ 5 ] = { "a", "b", "c", "d", "e"}
When my button is pressed, it should choose a random element set a value to be that element. But this is not the point.
What I need help with is: how do I make it so, when an action happens, it selects a random element from that array, sets it as a value, waits a few seconds, sets that value back to 0 and deletes that element from the list. I know perfectly well how this is done in JavaScript, but I'm new to this so please help.
Concept (i am aware that the void loop() is not going to work but it's put as an example:
int x[ 5 ] = { "a", "b", "c", "d", "e"}
int chosenElement = 0;
void loop() {
random(x) = chosenElement //choose the random element and set the value as it
Serial.print(chosenElement);
wait(1);
//something to delete the previously chosen element from the array
chosenElement = 0;
Serial.print(chosenElement);
}
I just need it to be as simple as possible; choose random element from array, set value and print, remove randomised element from array.
I've seen another Topic about Arrays but they're all about choosing random numbers from a consecutive list.