PBasic Question. Please Help!
koolitude
Posts: 37
The following statement was used to display the compass bearing obtained from a digital compass.
DEBUG· 2,0,1, "Compass Bearing (0-359 Degrees ", DEC3 I2cData/10
This does work. But my question is how can·I store the value of (DEC3 I2cData/10)·for further manipulation?
I wanna write a program such that when the bearing = certain degree then do something else.
I tried to declare another variable to store the value:
Bearing VAR·Word
Bearing = DEC3 I2cData/10
Then I got an error message:
Expected a constant, variable, unary operator, or '('
and the code DEC3 was highlighted:
Bearing = DEC3 I2cData/10
Please Help! Thanks you very much!
·
DEBUG· 2,0,1, "Compass Bearing (0-359 Degrees ", DEC3 I2cData/10
This does work. But my question is how can·I store the value of (DEC3 I2cData/10)·for further manipulation?
I wanna write a program such that when the bearing = certain degree then do something else.
I tried to declare another variable to store the value:
Bearing VAR·Word
Bearing = DEC3 I2cData/10
Then I got an error message:
Expected a constant, variable, unary operator, or '('
and the code DEC3 was highlighted:
Bearing = DEC3 I2cData/10
Please Help! Thanks you very much!
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Right idea, but the wrong syntax. Try this:
Bearing VAR Word
Then after the bearing is fetched
:
Bearing = I2cData
That's all there is to it. After that, it's just a matter of checking Bearing for whatever value you need to check, like these examples:
IF Bearing > 180 AND Bearing < 270 THEN GOTO SomeLabel 'One line format
or
IF Bearing < 90 OR Bearing > 180 THEN· 'Multi-line format:
· Count = Count + 1
· Flag = 1
ELSE
· Count = Count -1
· Flag = 0
etc.
Regards,
Bruce Bates
Thank you Bruce! I can now compile the program~ so... the problem was adding DEC3 in front of I2cData, right?
DEC3 is only used for formatting in the debug windows? am I right?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support