You can’t print an array in that way.

If you want to print an array of hexadecimal value (with two digits), you have to use sprintf function and change declaration of b array.

uint8_t b[]= {0x7E, 0x00, 0x1C, 0x90, 0x00, 0x13, 0XA2, 0x00, 
              0x41, 0x58, 0x1C, 0xCB, 0xFF, 0xFE, 0xC1, 0x7C, 
              0x00, 0x0F, 0x00, 0x01, 0x00, 0x00, 0x37, 0x46, 
              0x46, 0x46, 0x00, 0x00, 0x00, 0xE7};
int i;

void printHex(uint8_t num) {
  char hexCar[2];

  sprintf(hexCar, "%02X", num);
  Serial.print(hexCar);
}

void setup() {
  Serial.begin(9600);
}

void loop() {
  for(i=0; i<sizeof(b); i++){
    printHex(b[i]);
 }

 Serial.println();
 delay(500);
}

The output produced is:

7E001C900013A20041581CCBFFFEC17C000F0001000037464646000000E7 7E001C900013A20041581CCBFFFEC17C000F0001000037464646000000E7 7E001C900013A20041581CCBFFFEC17C000F0001000037464646000000E7

Answer from leoc7 on Stack Exchange
Discussions

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
arduino - How to `Serial.print()` "full" hexadecimal bytes? - Stack Overflow
I am programming Arduino and I am trying to Serial.print() bytes in hexadecimal format "the my way" (keep reading for more information). That is, by using the following code byte byte1 = 0xA2; byte More on stackoverflow.com
🌐 stackoverflow.com
How to serial print an array?
I've been trying to find a way to print an array with the Serial.print command. So far the code I've got looks like so (everything in the loop before the floats is fairly irrelevant): template inline Print &operator More on forum.arduino.cc
🌐 forum.arduino.cc
3
0
April 16, 2016
How to coerce Serial.print to print bytes as ASCII characters
How can I coerce Serial.Print to print a byte as an ASCII character rather than a decimal number ? #define My_SW_Ver 'e'; Serial.println(My_SW_Ver); works as intended - the result is 'e' if I do: byte SW_Ver; SW_Ver = My_SW_Ver; Serial.println(SW_Ver); the result is: '101' which is the decimal ... More on forum.arduino.cc
🌐 forum.arduino.cc
5
0
June 1, 2023
🌐
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 › 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 serial print an array? - Programming - Arduino Forum
April 16, 2016 - I've been trying to find a way to print an array with the Serial.print command. So far the code I've got looks like so (everything in the loop before the floats is fairly irrelevant): template<class T> inline Print &op…
Find elsewhere
🌐
Arduino Forum
forum.arduino.cc › projects › programming
How to write to serial a byte array with dynamic array? - Programming - Arduino Forum
December 10, 2018 - Hi, I started programming with esp8266. Everything is okey but I have a problem with serial write. I want to write to serial port for communicate with microcontroller. I'll send data like this format: Total 5 Byte : "…
🌐
TutorialsPoint
tutorialspoint.com › string-to-bytearray-in-arduino
String to byteArray in Arduino
July 24, 2021 - ArduinoHardwareSoftware & Coding · The getBytes() function helps copy the content of a String to a byte array. The syntax is − · string1.getBytes(buf,len) where, string1 is the string whose content you want to copy to a byte array, buf is the byte array, and · len is the length of content ...
Top answer
1 of 1
1

you can use bitwise operators, in particular Bitshiftleft "<<" and than Bitwiseor "|".

Fron Arduino documentation:

Bitshiftleft "... The left shift operator << causes the bits of the left operand to be shifted left by the number of positions specified by the right operand. ..."

Bitwiseor "... The bitwise OR operator in C++ is the vertical bar symbol, |. Like the & operator, | operates independently each bit in its two surrounding integer expressions, but what it does is different (of course). The bitwise OR of two bits is 1 if either or both of the input bits is 1, otherwise it is 0. ..."

The type of the variable have to be changed from byte to int, but beware that You have to choose between int or unsigned int based on your needs. An int represented as binary has the highest value (most left) used to define if the number is negative or positive.

You can start from something like this:

byte digitLeftZero[8] = {0b0000, 0b0110, 0b1001, 0b1001, 0b1001, 0b0110, 0b0000, 0b0000};
byte digitRightZero[8] = {0b0000, 0b0110, 0b1001, 0b1001, 0b1001, 0b0110, 0b0000, 0b0000};
byte digitDoubleZero[8] ;

byte a = 0 ;
byte b = 0 ;
byte c = 0 ;


void setup() {

  // open the serial port at 9600 bps:
  Serial.begin(9600);

  // Loop through arrays
  for (byte i = 0; i <= 7; i++) {

    a = digitLeftZero[2] ;
    b = digitRightZero[2] ;

    // debug
    Serial.print(i);
    Serial.print(" - ") ;
    Serial.print(a, BIN);  // print as an ASCII-encoded binary
    Serial.print(" - ") ;
    Serial.print(a << 4, BIN) ;
    Serial.print(" - ") ;

    c = a << 4 | b ;

    // output as binary representation
    Serial.println(c, BIN);  // print as an ASCII-encoded binary

    // assign values to target array
    digitDoubleZero[i] = c ;
  }
}

void loop() {

}

There is a tutorial in Arduino website that can be useful. "Bit math with Arduino" https://docs.arduino.cc/learn/programming/bit-math

🌐
GitHub
gist.github.com › 94327
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.
🌐
Arduino Forum
forum.arduino.cc › forum 2005-2010 (read only) › hardware › interfacing
How to print byte array to lcd screen....???HELP - Interfacing - Arduino Forum
July 2, 2010 - Anyone that can help me and explain what is happening · Problem SOLVED! I am posting the code I used, so someone else who is experiencing with the same problem will get some help from here · The code prints the DECIMAL values stored in the array of dhtll_dat into our LCD!
🌐
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?
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › hardware and peripherals › hats and other add-ons
Byte Array from Arduino To Raspberry Pi - Raspberry Pi Forums
Serial.print(roll); Serial.print(","); Serial.print(pitch); Serial.print(","); Serial.println(heading); Or even wrap some JSON round it with https://github.com/bblanchon/ArduinoJson
🌐
Arduino
arduino.cc › en › Serial › Write
Serial.write() | Arduino Documentation
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.
🌐
Starting Electronics
startingelectronics.org › software › arduino › learn-to-program-course › 17-arrays
Arrays in Arduino Sketches
A for loop is used to get the contents of each element in the array in turn and print the values to the Serial Monitor window.
🌐
Arduino Forum
forum.arduino.cc › projects › programming
How to store and read a byte from an Array (Arduino Uno) - Programming - Arduino Forum
December 5, 2015 - Dear community, Please help, I'm trying to write a smal program to make the arduino drive a shift register. I would like the program to read the the values stored in myArray and store them in the variable "code" I can't manage to do so, the values are translated automatically to decemal values.
🌐
Arduino Forum
forum.arduino.cc › projects › interfacing w/ software on the computer
Receiving Byte Array over serial - Interfacing w/ Software on the Computer - Arduino Forum
February 6, 2022 - Hi all! I am currently struggling to receive a 4 byte array, containing 3 values and a sync byte (S, or 0x53). All values stay at 0, even though it is receiving serial data... I'm sending this byte array every 10ms. Here below is my code: byte RGB[3] = {0, 0, 0}; boolean newData = false; void setup() { Serial.begin(9600); Serial.println(" 0) { byte val = Serial.read(); if (val == 'S') { while (!Seri...