Two characters(char) from serial monitor in the one field of the matrix-Problem!
hi! can please me code(sample of code)?
i wrote program reads character serial monitor , converts byte (matrix) .
wonder how write 2 characters serial monitor in 1 field of matrix?
this first program arduinom!
this code:
current printout;

i want printout;

can write in 4th row, sectorkey [3] [0-5] , in 1,2 , 3 row remain values in in picture 2??
i'm sorry eng!
any appreciated. thanks.
i wrote program reads character serial monitor , converts byte (matrix) .
wonder how write 2 characters serial monitor in 1 field of matrix?
this first program arduinom!
this code:
code: [select]
byte sectorkeya[16][16];
byte var[16][16]={
{
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;
( x=0; x < 6; x++){
int y;
(y=0; y < 4; y++){
var[y][x] = serial.read();
{
}
if (var[y][x] >= 0x30 && var[y][x] <= 0x39) // char dec 0 9
{ var[y][x]= var[y][x] - 0x30 ;
}
if (var[y][x] >= 0x61 && var[y][x] <= 0x66) // char dec "a" "f"
{
var[y][x]= var[y][x] - 0x61 +10;
}
if (var[y][x] >= 0x41 && var[y][x] <= 0x46)// char dec "a" "f"
{
var[y][x]= var[y][x] - 0x41 +10;
}
serial.print(var[y][x],hex);
}
}
serial.flush();
}
current printout;

i want printout;

can write in 4th row, sectorkey [3] [0-5] , in 1,2 , 3 row remain values in in picture 2??
i'm sorry eng!
any appreciated. thanks.
read 1 character. convert ascii binary. store in variable. shift contents of variable left 8. read second character. convert binary , add variable:
code: [select]
char h = 'f';
char l = 'f';
int r = hexasciitobinary(h);
r <<= 8;
r+= hexasciitobinary(l);
Arduino Forum > Using Arduino > Programming Questions > Two characters(char) from serial monitor in the one field of the matrix-Problem!
arduino
Comments
Post a Comment