Hello
Thanks a lot for your detailed explanation. As a beginner it helped me to understand the code in detailed manner .
I had some problems with the simulator to start with but i went through it and It helped me to understand about it in quite a bit details and it feels good. I did some additional programming to basically the shifting towards negative axis and positive axis,
I have currently incoming 15 bit binary vector That look like this
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 --> vec1
1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 --> vec 2
I wanted to compare each of the incoming vectors with a reference vector which I define as Reference_vector as
1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 --> ref vec
The idea was to define this as an Boolean array
boolean reference_array []= {1, 1, 1, 1, 1,1 ,1,1,1,0, 0, 0, 0, 0,0};
which is also a 15 bit array. I am not sure if this is the best way to define the bit vector in Arduino. I want to compare the incoming 15 bit stream with this reference_array and based on that I can say if it is to positive X direction or Negative X direction.
So for example if the incoming array is
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
and comparing it to reference array . there are three more 0s to the left of the reference_array and thus corresponding -3X in distance ?
and if its as follows
1 1 1 1 1 1 1 1 1 1 1 0 0 0 0
There are two more ones than the reference vector then it results in +2X distance
I am looking for a very simple way to do that manipulation. Perhaps bit shifting is the easiest way forward but I am not comfortable with that as of now. I am thinking on these lines
Binary_input [z] -->15 different values
for (int z=1; z<16;)
{
boolean reference_array []= {1, 1, 1, 1, 1,1 ,1,1,1,0, 0, 0, 0, 0,0};
if (//Binary_input[z]) and reference_array--> doing a comparison )
//No of Binary 0s is to the left of the reference vector for ex if its 3 zeros as shown above it will result in -3x )
else
(// If the shift there are 2 more 1s the number of ones in reference vector it result in +2x distance (as I tried to explain in the example)
z++;
}