How to `Serial.print()` “full” hexadecimal bytes?

前端 未结 6 1965
猫巷女王i
猫巷女王i 2021-01-18 02:17

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 u

6条回答
  •  花落未央
    2021-01-18 03:04

    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.
    

提交回复
热议问题