# Two characters(char) from serial monitor in the one field of the matrix-Problem!

I wrote a program that reads a character from the serial monitor and converts it to byte (matrix) .
I wonder how to write two characters from serial monitor in one field of the matrix?
This is my first program with arduinom!

This is my code:

``````byte sectorKeyA;
byte var={
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF  }
,
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF  }
,/// / ko ga poskusite znova, ga spremenite v vašo novo geslo
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF  }
,
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF  }
,
};
void setup()
{
Serial.begin (9600);
}

void loop()
{
while (Serial.available()<24 );
{
}
int x;
for ( x=0; x < 6; x++){
int y;
for (y=0; y < 4; y++){
{
}
if (var[y][x] >= 0x30 && var[y][x] <= 0x39)  // char too DEC from 0 to 9
{ var[y][x]= var[y][x] - 0x30 ;
}
if (var[y][x] >= 0x61 && var[y][x] <= 0x66) // char too DEC from "a" to "f"
{
var[y][x]= var[y][x] - 0x61 +10;
}
if (var[y][x] >= 0x41 && var[y][x] <= 0x46)// char too DEC from "A" to "F"
{
var[y][x]= var[y][x] - 0x41 +10;
}
Serial.print(var[y][x],HEX);
}
}
Serial.flush();
}
``````

Current printout;

I want this printout;

Can I just write in the 4th row, sectorkey  [0-5] and in 1,2 and 3 row remain values like in as in the picture 2??
I’m sorry for my ENG!

Any help appreciated. Thanks.  Read one character. Convert it from ASCII to binary. Store it in a variable. Shift the contents of the variable to the left by 8. Read the second character. Convert it to binary and add it to the variable:

``````char h = 'F';
char l = 'F';

int r = hexASCIItoBinary(h);
r <<= 8;
r+= hexASCIItoBinary(l);
``````

{I} {suggest} {that} {you} {learn} {when} {curly} {braces} {are} {required} {and} {when} {they} {are} {not}.

Thank you Arrch for the answer!