Why does variable revert to previous value?

And used outside of that function "sizeof(chars)" returns the number of bytes occupied in the array,

You haven't posted all the code, but I suspect that outside the printer() function you are referring to a global array called "chars", inside that function it's a local pointer to an array.

Change the name of the parameter to anything except "chars" then try sizeof(chars), I think you will get what you want.

That said unless the string in chars is always the full length of the array sizeof() is of no use anyway (and if it was you'd just use a constant), so strlen() is the way to go.

I convert it to the decimal equivalent of that ASCii character. However, it immediately changes back to ASCii.

I assume you're referring to this

chars[i] -= '0';
      Serial.println(chars[i], DEC);

If you use DEC and println() it will ASCIIize the value (probably adds the '0' right back again). Use Serial.write() if you want the binary value to be transmitted.


Rob