Serial, ints and chars

How come returns an int? Isn’t that twice the memory needed to pass all possible values? The microcontroller used in the Arduino board is an 8bit device right? So every call using an int takes twice the processing time? Shouldn’t return a char instead?


It returns an int so it can return -1 if there’s no character available. If you know there is (e.g. because you just called Serial.available()), you can simply assign it to a char, e.g.

char c;

if (Serial.available())
  c =;

It’s perhaps slightly less efficient, but not significantly (e.g. compared with the time it take to transmit the data over the serial port).