Hi! Can someone please help me with my code(sample of code)?
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[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;
for ( x=0; x < 6; x++){
int y;
for (y=0; y < 4; y++){
var[y][x] = Serial.read();
{
}
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 [3] [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.