title: Arduino Function converting char* to byte array
body: <p>I am trying to create a function in Arduino to convert a string into an array of byte ascii hexadecimal values. I barely understand c, so I apologize for such a complicated way of trying to do what I figure must be simple, but here it goes:</p>
  <p><strong>Input</strong> &quot;AAA&quot; </p>
  <p><strong>Output/Expected result</strong>:  final[ ] = {0x41,0x41,0x41,...}</p>
  <pre><code>void enviarMsj(const String&amp; message){
    char mensaje[message.length()]; 
    String temp;
    char buf[4];
    uint16_t final[30];
     
    for(int i = 0; i &lt; message.length(); i++){
        temp = &quot;0x&quot; + String(message.charAt(i), HEX);
        temp.toCharArray(buf,5);
        final[i]= buf;   
     }
    }
  
  </code></pre>