So I've found something with Serial.print that strikes me as odd, but I'm not sure if it's a bug or just the way things are intended to work. The short test program below produces the problem. If I define an array of characters, and try to use Serial.print to print the value of an element of that array, it prints nothing unless I specify HEX or DEC base in the Serial.print statement.
Here's the output of the program below:
System Startup, test 01
print without specifying base:
print as hex: 2
print as dec: 2
My question is "Why didn't Serial.print print a 2 at the end of line two above?"
byte const IDX = 1; // memory array index
char cArray[4]; // array of characters
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(F("System Startup, test 01"));
cArray[IDX] = 2; // put a value in array
Serial.print(F("print without specifying base: "));
Serial.println(cArray[IDX]);
Serial.print(F("print as hex: "));
Serial.println(cArray[IDX], HEX);
Serial.print(F("print as dec: "));
Serial.println(cArray[IDX], DEC);
}
void loop() {
// put your main code here, to run repeatedly:
}