View Single Post
  #3   Spotlight this post!  
Unread 20-02-2011, 15:31
Hadyn Fitzgeral Hadyn Fitzgeral is offline
Registered User
None #1234
 
Join Date: Feb 2011
Rookie Year: 2013
Location: No where
Posts: 3
Hadyn Fitzgeral is an unknown quantity at this point
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]
Reply With Quote