inquiry about the motion sensor example

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
khaled yasin
Posts: 43
Joined: Sat Sep 13, 2008 10:36 pm
Contact:

inquiry about the motion sensor example

Post by khaled yasin »

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???

Sean
Valued Contributor
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

Post by Sean »

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 << 8), equivalent to multiplication by 256, to become the high half of 16-bit value before adding to CaptureL (the low half).

Post Reply