Hello,
I'm new to Arduino. I'm using leonardo.
I have mac address stored in a string
String eth="DEADBEEFFEED";
i want it to convert it to :
byte eth_mac[] = {0XDE,0xAD,0xBE,0xEF,0xFE,0xED };
help please !!!
Thanks
Hello,
I'm new to Arduino. I'm using leonardo.
I have mac address stored in a string
String eth="DEADBEEFFEED";
i want it to convert it to :
byte eth_mac[] = {0XDE,0xAD,0xBE,0xEF,0xFE,0xED };
help please !!!
Thanks
I have mac address stored in a string
String eth="DEADBEEFFEED";
Why?
In a loop that iterates 6 times, read a character. Convert that character to a number, in the range 0 to 15. Multiply by 16. Read another character. Convert that character to a number, in the range 0 to 15. Add to the first value. There, you have a byte.
The first part:
char letter = eth[i];
byte val = 0;
if(letter >= '0' && letter <= '9')
val = letter - '0';
else if(letter >= 'A' && letter <= 'F')
val = letter - 'A' + 10;
I'm sure you can figure out the rest.