For a school project I need to randomly turn on LEDs in a color that is randomly chosen. So for example you can choose between red, blue, yellow and green. Then you need to pick one color randomly and randomly situated LEDs of that specific color on. The amount of LEDs that need to be turned on is input from the main document, I am trying to write these functions in a different class.
I need different arrays that contain the different LEDs of that color like:
int GrLeds[] = {LED_1, LED_5}; //the amount of LEDs can be changed
int ReLeds[] = {LED_2, LED_6};
int BlLeds[] = {LED_3, LED_7};
int GrLeds[] = {LED_4, LED_8);
Then one of these colors needs to be chosen randomly. I thought about putting the different color option in an array like the following:
int randomClr[] = {ledG, ledR, ledB, ledY};
But doing it like this would require me to link the ledG to GrLeds[] etc.
Is there a possibility to choose one of the arrays randomly, or something what would result in the same? I know Java has the option to use a list but that does not seem to be possible within c++.
Aucun commentaire:
Enregistrer un commentaire