|
Re: Photoswitch value?
A Photoswitch Has 2 Values
On and Off
Or 0/1
This can be translated into binary and using a bitmask we can get values either know as Opcodes to translate into robot movement.
byte mask = 0;
if(sensor0 is active)
mask |= 0x1;
if(sensor1 is active)
mask |= 0x2;
if(sensor2 is active)
mask |= 0x4;
return mask;
MIN OPCODE = 0, MAX OPCODE = 7 [2^0 + 2^1 + 2^2]
|