Hi!
Having following situation:
for my fiddle yard (model railroad) i need for changing the rail position a binary goto command:
0000 ... rail1
0001 ... rail2
0010 ... rail3
My arduino one board becomes these command out of the nmra-dcc lib:
if (BoardAddr == Addr1 && State == 8) { // Sollposition
switch (OutputAddr) { // ungerade Zahl ist gerade (0) und abzweigend ist gerade Zahl (1)
case 1:
posState[0] = 0;
break;
case 0:
posState[0] = 1;
break;
case 3:
posState[1] = 0;
break;
case 2:
posState[1] = 1;
break;
case 5:
posState[2] = 0;
break;
case 4:
posState[2] = 1;
break;
case 7:
posState[3] = 0;
break;
case 6:
posState[3] = 1;
break;
}
}
As you see I want to store the binary command into an array because I couldn't get them at the same time because of the turnout commands.
Now my problem is to convert this array into a binary variable.
Could you help me - my suggestion is:
byte pos = 'B'+posState[3]+posState[2]+posState[1]+posState[0];
but does not work.
Please help!