i downloaded a flow code 3 example about motion sensor,why when it measure the distance it calculates it like this
Distance = ( CaptureH << 8 ) + CaptureL why no. 8 and added to captureH???
inquiry about the motion sensor example
-
- Posts: 43
- Joined: Sat Sep 13, 2008 10:36 pm
- Contact:
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: inquiry about the motion sensor example
The Distance variable is a 16-bit integer. CaptureH and CaptureL are two 8-bit byte variables that represent the two halves of a 16-bit value.
CaptureH must be left-shifted by 8 bit positions (using <<
, equivalent to multiplication by 256, to become the high half of 16-bit value before adding to CaptureL (the low half).
CaptureH must be left-shifted by 8 bit positions (using <<
