Replacing Array Value

Hey,

Is there a way to replace a specific array value with another?

I have:

uint8_t checkingPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};

and i would like to update the second value to something else from a variable.

checkingPins[1] = someVal;
byte aVariable = 123;
checkingPins[1] = aVariable;  //note that arrays are indexed from zero so 1 is the second value

When i try both solutions it says

'checkingPins' does not name a type

eddcaton:
When i try both solutions it says

'checkingPins' does not name a type

Please post the entire sketch

eddcaton:
When i try both solutions it says

'checkingPins' does not name a type

then you've done something wrong, code outside a function, most likely

eddcaton:
When i try both solutions it says
'checkingPins' does not name a type

clearly he took both incomplete examples without declaring checkingPins...

TheMemberFormerlyKnownAsAWOL:
then you've done something wrong, code outside a function, most likely

Thanks All,
Yes i didn't have it in a function. All working now :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.