Simple brute force method, is to write a routine as:

void p(char X) {

   if (X < 16) {Serial.print("0");}

   Serial.println(X, HEX);

}

And in the main code:

p(byte1);  // etc.
Answer from JackCColeman on Stack Overflow
🌐
Arduino Getting Started
arduinogetstarted.com › reference › serial-print
Serial.print() | Arduino Getting Started
2 weeks ago - Learn Serial.print() example code, reference, definition. Prints data to the serial port as human-readable ASCII text. print() returns the number of bytes written, though reading that number is optional. What is Arduino Serial.print().
Discussions

Print Byte Array in Serial monitor screen of Arduino IDE - Arduino Stack Exchange
I need to print mentioned below byte array on the serial monitor screen of Arduino IDE char b[]= {'0x7E', '0x00', '0x1C','0x90', '0x00', '0x13', '0XA2', '0x00', '0x41', '0x58', '0x1C', '0xCB', '0x... More on arduino.stackexchange.com
🌐 arduino.stackexchange.com
How to print all the 8 bits of a byte on serial monitor, if they are all zero
Hi all, As per title... Assuming I have this variable: mybyte = 00000000. Whenever I print Serial.println(mybyte, BIN); I get 0 on the serial monitor. How would I change this so as to print the values of all the 8 bits? Thanks More on forum.arduino.cc
🌐 forum.arduino.cc
0
0
January 27, 2016
How to Leading Zero's Serial print of Byte
Hi there Im currently working on a project for school. I had print some byte values on the Serial Monitor with use of Serial.print(byte) So for example: Variable Byte is made, and given value 8. It has to be printed b… More on forum.arduino.cc
🌐 forum.arduino.cc
0
0
March 4, 2020
Serial.print(13, BYTE); equivalent command in Arduino 1.0
Serial.print(13, BYTE); when i write the following instruction i get a compile error message saying that BYTE is no longer supported what is the equivalent instruction to use in Arduino 1.0 More on forum.arduino.cc
🌐 forum.arduino.cc
0
0
January 1, 2012
🌐
Arduino
arduino.cc › en › Serial › Print
Serial.print() | Arduino Documentation
See the list of available serial ports for each board on the Serial main page. val: the value to print. Allowed data types: any data type. format: specifies the number base (for integral data types) or number of decimal places (for floating point types). The function returns the number of bytes written, though reading that number is optional.
🌐
Arduino Forum
forum.arduino.cc › projects › programming
How to print all the 8 bits of a byte on serial monitor, if they are all zero - Programming - Arduino Forum
January 27, 2016 - Hi all, As per title... Assuming I have this variable: mybyte = 00000000. Whenever I print Serial.println(mybyte, BIN); I get 0 on the serial monitor. How would I change this so as to print the values of all the 8 b…
🌐
Arduino Forum
forum.arduino.cc › projects › programming
How to Leading Zero's Serial print of Byte - Programming - Arduino Forum
March 4, 2020 - Hi there Im currently working on a project for school. I had print some byte values on the Serial Monitor with use of Serial.print(byte) So for example: Variable Byte is made, and given value 8. It has to be printed b…
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Serial.print(13, BYTE); equivalent command in Arduino 1.0 - Programming - Arduino Forum
January 1, 2012 - Serial.print(13, BYTE); when i write the following instruction i get a compile error message saying that BYTE is no longer supported what is the equivalent instruction to use in Arduino 1.0
Find elsewhere
🌐
Arduino
arduino.cc › en › Serial › Write
Serial.write() | Arduino Documentation
See the list of available serial ports for each board on the Serial main page. ... The function returns the number of bytes written, though reading that number is optional. Data type: ... 8 int bytesSent = Serial.write("hello"); //send the string "hello" and return the length of the string.
🌐
Arduino
arduino.cc › en › Serial › Println
Serial.println() | Arduino Documentation
See the list of available serial ports for each board on the Serial main page. val: the value to print. Allowed data types: any data type. format: specifies the number base (for integral data types) or number of decimal places (for floating point types). The function returns the number of bytes written, though reading that number is optional.
Top answer
1 of 5
38

Serial.write is more down to earth , it is simple and fast, it is made to talk binary, one byte at a time. example:

Serial.write(0x45);   // will write 0100 0101 to the cable

Serial.print in the other hand is more versatile , it will do the conversion for you from ASCII to binary it also can convert to BIN/ HEX/OCT/DEC but you need to specify a second argument like so

Serial.print(76, BIN) gives "0100 1100"
Serial.print(76, OCT) gives "114"
Serial.print("L", DEC) gives "76"
Serial.print(76, HEX) gives "4C" 

more examples with visual serial output :

Code:

  Serial.write(0x48);   // H
  Serial.write(0x45);   // E
  Serial.write(0x4C);   // L
  Serial.write(0x4C);   // L
  Serial.write(0x4F);   // O

SERIAL OUTPUT :

Code:

  Serial.print("HELLO");

SERIAL OUTPUT :

Serial.println() in the other hand will add end of line 2 bytes 0x0D and 0x0A as you can see in the frame

Code:

  Serial.println("HELLO");

SERIAL OUTPUT :

2 of 5
25

From the Arduino site for Serial.write and Serial.print:

Serial.write()

Writes binary data to the serial port. This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead.

Serial.print()

Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is

🌐
GitHub
gist.github.com › njh › 1b5eb27c24834f4a4cb5a65ad6b2c1dd
Arduino sketch to receive bytes from Serial Port 1 and print them in hex to the Serial Monitor · GitHub
Arduino sketch to receive bytes from Serial Port 1 and print them in hex to the Serial Monitor - RS485_Serial_Echo.ino
🌐
Arduino Forum
forum.arduino.cc › projects › general guidance
Print and Write data using 13 byte array - General Guidance - Arduino Forum
July 29, 2021 - Hi, I am trying to send and print the 13 bytes of data using serial communication using Arduino Uno board, when I use print function the data is not matching with that of actual data present in the array, how to properly print the data present in the array in binary format with 13 bytes of data byte data_out[] = {0b00000000,0b00000001,0b00000010,0b00000011,0b00000100,0b00000101, 0b00000110,0b00000111,0b00001000,0b00001001,0b00001010,0b00001011, 0b00001100,0...
🌐
Arduino Forum
forum.arduino.cc › forum 2005-2010 (read only) › software › syntax & programs
How to print byte as string? - Syntax & Programs - Arduino Forum
November 21, 2010 - Hi, I save some values in EEPROM, so I save them as byte. When I want to print these values I somehow need to convert the to a string... Is there a function to do this?
🌐
GitHub
gist.github.com › 94327 › b3d8a93effa0fb4d79ed307b691107ea1068fcea
Simple updated examples of arduino serial communications · GitHub
if (Serial1.available()) { Serial.print(Serial1.read(),HEX); } This is just a simple pass through code and but what i need is to take the 4 bytes for the distance and convert them to a decimal number.
🌐
Hackster.io
hackster.io › Hack-star-Arduino › how-to-print-hexadecimal-and-binary-on-to-serial-monitor-5e5d11
How to print hexadecimal and Binary on to Serial Monitor? - Hackster.io
December 26, 2022 - Project link:https://wokwi.com/arduino/projects/324197069182992979 · you have many ways to ask for help, suggest a feature, or share your feedback ... Hop on to Discord Server! ... /* Uses a for loop to print numbers in various formats. */ void setup() { Serial.begin(9600); // open the serial port at 9600 bps: } void loop() { // print labels Serial.print("NO FORMAT"); // prints a label Serial.print("\t"); // prints a tab Serial.print("DEC"); Serial.print("\t"); Serial.print("HEX"); Serial.print("\t"); Serial.print("OCT"); Serial.print("\t"); Serial.print("BIN"); Serial.println(); // carriage