Numbers are just numbers, and there's no way for the Arduino to know that you used a hex value for initialization instead of a decimal, octal, or binary value. So you have to explicitly tell print() how you want it printed, as michinyon says...
Thanks michinyon and westfw for your help. The output is now hexadecimal. I'm getting:
2 63 6E 0
However, I also need the leading zero for the 2 and 0 ; like so:
02 63 6E 00
I can't figure out why it's being drop. How can I remedy this. Again, thanks in advance for your support. This is by far the best forum I've ever experienced. Here's my updated code:
char foo[4] = {0x02,0x63,0x6e,0x00};
void setup(){
Serial.begin(19200);
delay(3000);
for ( int i=0 ; i<4 ; i++ )
{
Serial.print( foo*, HEX ) ;*
AWOL, I'm a beginner with the C language and require quite a bite of patience from you guys (Lol :)). I've tried many combinations, but not getting the desired output. Here's the best combination so far, but it's dropping the 63 and 6E. I'm getting
The code I wrote fits as written into the code you posted earlier.
Think - the problem is that you're missing leading zeroes on values, so you need to supply those zeroes in the required cases before you print the values.
This isn't a programming problem, it is simple logic.
Because it's useless. 02 and 2 are the same value. They are not the same string, but you aren't printing strings. You are printing values. If you want to print strings, or values as strings, you are going about it wrong. sprintf() bears looking at.