Hi,
I have a trivial problem, that i have been wracking my brains over for the last week. Getting dumber as i get older 
The idea is that a sequence of infra red LED's gets turned on in relation to the binary count on PortA. This also turns on an associated detector.
Whatever the output of the detector, it gets written to the variable DataIn2.
So, after a full 8 bits the data in DataIn2 should look like 10010110, in this case the beam has been interrupted at positions 1, 4, 6, & 7.
The code below does this, but obviously knocks of the first bit, due to it moving the bit to the left to concatenate the variable - so the example now looks like 00010110. How do i get the complete 8 bits into the variable?
Code:
BinaryCount: 'Advances LED and detector 1 place
PortA = BinCount 'Pushes Binary value of BinCount onto PortA
Pause 10 'Pause to let detectors start up
If PortB.0 = 1 Then 'monitor PortE.2 for beam break
DataIn2 = DataIn2 + 1 'something blocking beam, write a 1 to DataIn2 variable
DataIn2 = DataIn2<<1 'Move bit one place to left to concatinate variable
Else
DataIn2 = DataIn2 + 0 'Beam clear, write a 0 to DataIn2 variable
DataIn2 = DataIn2<<1
EndIf
If BinCount = 7 Then
BinCount = 0 'Reset when we get to end of LED's
Gosub Display
Else
BinCount = BinCount + 1
EndIf
Return
Bookmarks