variable int in array

hello world!!!
Is it possible to make an array of fixed integers and one variable that is changing due analogread?e.g. something like that array={0,0,0,var,var,var}; where var is changing.

If you know the index of the variable elements, sure.

No, declare and initialize your array to 0s:


Then change the values when required, as in

array[3] = var;

hmmm good and if my array consist of binary logic like
int CWH={0x5,0x4,0x4,0x4,0x6,0x2,0x2,0x2,0x3,0x1,0x1,0x1}; and i want 5 of this make to be variables? e.g. from 5th to 10th position?

Can you explain what it is you want to do, not how you think you ought to do it?

Unless you declare the array as const, any of the elements can be changed at any time, the fact you do not intend to ever change some of the elements is irrelevant.

ok i want that array will be controlling arduino outputs directly by position in array.some outputs are on or off but i want that some of them will be pwm changable.

some of them will be pwm changable.

Presumably the maximum value will be 255 for these so an array of bytes would be sufficient. With extra programming it would be possible to combine up to 8 on/off values in a single byte but the overhead is probably not worth it.

I imagine the OP thinks he can have some values automagically updated without having to set them. Like when someone writes:

int state = digitalRead(pin);

at global scope and then doesn't understand why the variable doesn't keep track of the pin.

OP, you can have any number of values in an array. But they're just values. They're all variables. But they just hold values. None of them is going to do any magical automatic tracking of anything else. You'll have to set the value every time you want it to change.