Use the UART – see here

Menu > Tools > Serial Monitor sop see its output

Enable the serial port

  //Serial.begin(9600);    //May as well run it at fast speed of 115200
  Serial.begin(115200);
  while(!Serial)
    ;

Strings

Print const string
  Serial.println(F("Hello"));

Note the “F( )” avoids the compiler storing the string in RAM (dynamic) memory by default

Print array as char string
  Serial.println((char*)buffer);
Printing Multiple Strings
  Serial.println("Hello " + MyStringName);
Print A Character
  Serial.print((char)c);

Specific variable types

Integer
  Serial.print(variable1, DEC);
Hex
  Serial.print(variable2, HEX);
Binary
  Serial.println(variable3, BIN);
Float
  Serial.println(my_float_value, 3);

Will print to 3 decimal places

64bit value
//Serial.print does not support 64bit, so we use this
void SerialPrintUint64 (uint64_t value)
{
  char rev[22]; 
  char *p = rev + 1;

  while (value > 0)
  {
    *p++ = '0' + ( value % 10);
    value /= 10;
  }
  p--;
  //Print the number which is now in reverse
  while (p > rev)
    Serial.print(*p--);
}

Examples

  Serial.print(F("Received: "));
  Serial.print(variable1, DEC);
  Serial.print(F(", "));
  Serial.print(variable2, HEX);
  Serial.print(F(", "));
  Serial.println(variable3, BIN);
  Serial.println(tx_data[0], HEX);
  Serial.println(tx_data[1], HEX);
  Serial.println(tx_data[2], HEX);
  Serial.println(tx_data[3], HEX);
  Serial.println(tx_data[4], HEX);
  Serial.println((p_buffer - tx_data), DEC);