28125 Parallax Inc, 28125 Datasheet - Page 85

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
ACTIVITY #5: HOW TO STORE VALUES AND COUNT
This activity introduces variables, which are used in PBASIC programs to store values.
Boe-Bot programs later in this book will rely heavily on variables. The most important
thing about being able to store values is that the program can use them to count. As soon
as your program can count, it can both control and keep track of the number of times
something happens.
Using Variables for Storing Values, Math Operations, and Counting
Variables can be used to store values. Before you can use a variable in PBASIC, you
have to give it a name and specify its size. This is called declaring a variable.
The next example program just involves a couple of word variables:
After you have declared a variable, you can also initialize it, which means giving it a
starting, or initial, value.
variableName VAR Size
value
anotherValue
value = 500
anotherValue = 2000
Your servos do not need to be connected to power for this activity.
You can declare four different sizes of variables in PBASIC:
battery pack, but leave the 9 V battery connected to the battery clip. This
disconnects power from the servo ports, but power remains connected to the
embedded BASIC Stamp, Vdd, Vin, and Vss.
If you have a Board of Education Rev C, set the 3-position switch to position-1.
This disconnects power from the servo ports only. The BASIC Stamp, Vdd, Vin,
and Vss will all still be connected to power.
If you have a BASIC Stamp HomeWork Board, remove one battery from the
Size
Bit
Nib
Byte
Word
VAR
VAR
Stores
0 to 1
0 to 15
0 to 255
0 to 65535
or -32768 to + 32767
Word
Word

Related parts for 28125