So I've been programming for my arduino which is some variant of c++. I have been writing a program to tick through every number of a 4 digit seven segment display. I have been having trouble setting my pins[] to different arrays of different lengths.
For example, displaying one means 2 pins will be on, which are expressed in the array int one[] = {1,2};
and displaying four takes four pins int four[] = {1,2,3,4};
.
What I've been trying is:
int pins[] = null;
int one[] = {1,2};
int four[] = {1,2,3,4};
switch(num) {
case 1: pins = one; break;
case 4: pins = four; break;
}
However this has been causing problems and isn't letting me upload it because things just break everywhere.
I have a limited knowledge of of c++, only that it's similar to Java, which I know quite a bit about.
I feel like I'm feeding sharks with insufficient protection, and this one bit in my code is bugging me.
My question is how do you initialise an array, but then change it later on?