hi
This should be really easy but i can't work it out.
How do I read 4 pins into a byte?
Something along these lines maybe?
B4X:
dim s as byte
For i = 0 To 3
Dim f As Boolean
f = rly(i).DigitalRead
If f = True Then
'some part of byte s = 1
Else
'some part of byte s = 0
End If
next
dim s as byte =0
Dim s2 as byte=0
dim mask as int=1
For i = 0 To 3
Dim f As Boolean
f = rly(i).DigitalRead
If f = True Then 'some part of byte s = 1
'This will work
s=Bit.Or(s, Bit.ShifLeft(1,i)) ' pins 0 to 3 will be in bits 0 (weight=1) to 3 (weight=8)
'This is basically the same
s2 = s2 + mask
Else
'some part of byte s = 0 --> just do nothing
End If
mask=mask*2
next
Log("Result is "&s)
Log("Result is "&s2)