Parallax Boe-Bot Student Manual page 339

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Now, we know how to correct the
the
variable in this narrow range of light levels:
timeRight
=
+
y
mx
b
=
+
y
. 1
37
x
7
=
timeLeft
(
adjusted
)
A Linear Equation in PBASIC
In most programming languages for PCs, this equation could be entered as-is. The
BASIC Stamp is a very tiny processor compared to a PC. Because of this, it takes an
extra step to multiply by a fractional value. You have to use the */ operator (it's called
the "star-slash" operator). For the
variable can be done like this:
timeLeft
timeLeft = (timeLeft */ 351) + 7
The adjusted value of
timeLeft
, plus 7.
timeLeft
Why did 1.37 become 351? The way the */ operator works is that you have multiply your
fractional value by 256, and place it to the right of the */ operator. Since 1.37 X 256 =
350.72 ≈ 351, the value 351 goes to the right of the */ operator.
You can find out more about the */ operator in the BASIC Stamp Editor by clicking Help and
selecting Index. Type in */ in the field labeled "Type in keyword to find". You can also look
up */ in the Binary operators section of the BASIC Stamp Manual.
Your Turn – Balance Your Photoresistors with m and b
In Table F-1, label the first
X2.
Label the first
timeRight
Use these equations and your X1, X2, Y1, and Y2 values to solve for m and b.
y (
y
)
=
2
1
m
x (
x
)
2
1
and
Appendix F: Balancing Photoresistors · Page 325
variable so that it reports values similar to
timeLeft
×
+
. 1
37
timeLeft
7
equation, the PBASIC code to adjust the
timeLeft
after this line of code is executed is 1.37 times the old
entry X1 and the second
timeLeft
entry Y1 and the second
=
b
y
mx
2
2
timeLeft
entry Y2.
timeRight
entry

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Boe-Bot and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF