dannable:
Is the fact that you have eight sensors and the bit pattern is eight characters long any way connected?
Yes. Each bit of data on the strings above represents an individual sensor.
HazardsMind:
Where does "1111 1111 and 0000 0000" come from?
The 8 bit pattern represents the actual sensor outputs.
The right 4 digits represent Front and rear right and the other 4 digits represent Front and rear left.
dannable:
If you want to control your motors using nibbles, then you would need to mask off which nibbles go where.
So for example, 1010 | 0101 -> leftSide | rightSide
data = 10100101 => data >> 4 = 00001010 = leftSide.
----------------- => data & 0x0F = 00000101 = rightSide.
Not sure if this would work. Because sometimes i need to read a full string to indicate a change in direction. For example, assuming 1010 means the sensor is aligned. So i should read 1010 1010. However, before a curve I will read 1010 0001, where the first strig is used to indicate sync and the second indicates a right curve ahead, so I need to be able to interpret this.
dannable:
Now since you want to use the nibbles to control the speed, you would need to multiply the leftSide by 17, because 15 * 17 = 255.
And for rightSide you would either need to subtract 15 from rightSide, then multiply it by 17, or just format the nibble the correct way. Yours is 0101, where it should be 1010 to make things easier.
Ill have several combinations, but that would not work.
The robot folows a thick line (6cm)
Basically:
0000 means turn left (way out of sync)
1010 means the sensor is synced, hence one is reading the black line (inner) and the other is reading the outer white space with the rear aligned.
1011 means the front sensor is aligned, but the rear is out, so I need to turn a bit to go into aligment again
1111 means both sensors are out of the line and i need to turn right.
On the first case, only an adjustment is needed, hence the PWM is reduced to make a smooth turn (1011). On the second, the whole thing is out, so one of the motors is disabled and the speed of the other one is reduced until sync is regained on one sensor
I am also assuming you refer to the 255 as the PWM register, but can you post a line of code to actually enable the PWM and interface both, that can serve as an example?
Kind regards