I want to read pin values and put them in a “buffer”. My program is like this:

int buffer[361] = 0;
void setup()
void loop()
for(int i=0;i<361;i++)

  • }*

    But it seems the values can not be written into the array, and some members of the array even have very absurd values. If I output the values of the pins directly then everything is fine. The problem is that they can’t be written into the array.

Your only reading one pin at a time. and placing it into your array. then advancing your array.

You would need a more sophisticated loop within a loop and add the values of each pin according to their position.

Or better yet, read all pins at once and place that value into your array.

Follow the link to read all pins at once (actually the register to where they lay)


You might try removing the = 0 from the line declaring the array, or replacing it with = { 0 } . Otherwise, you might try making the array smaller, as it's possible there's not enough RAM for that many elements.