EasyManuals Logo

Parallax Boe-Bot User Manual

Parallax Boe-Bot
360 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #167 background imageLoading...
Page #167 background image
Chapter 4: Boe-Bot Navigation · Page 153
Example Program – EepromNavigationWithWordValues.bs2
This next example program looks complicated at first, but it is a very efficient way to
design programs for custom Boe-Bot choreography. This example program uses
EEPROM data storage, but does not use subroutines. Instead, a single code block is
used, with variables in place of the
FOR...NEXT loop's EndValue and PULSOUT Duration
arguments.
By default, the
DATA directive stores bytes of information in EEPROM. To store word-
sized data items, you can add the
Word modifier to the DATA directive, before each data
item in your string. Each word-sized data item will use two bytes of EEPROM storage,
so the data will be accessed via every other address location. When using more than one
DATA directive, it is most convenient to assign a label to each one. This way, your READ
commands can refer to the label to retrieve data items without you having to figure out at
which EEPROM address each string of data items begins. Take a look at this code
snippet:
' addressOffset 0 2 4 6 8
Pulses_Count DATA Word 64, Word 24, Word 24, Word 64, Word 0
Pulses_Left DATA Word 850, Word 650, Word 850, Word 650
Pulses_Right DATA Word 650, Word 650, Word 850, Word 850
Each of the three DATA statements begins with its own label. The Word modifier goes
before each data item, and the items are separated by commas. These three strings of
data will be stored in EEPROM one after another. We don’t have to do the math to
figure out the address number of a given data item, because the labels and the
addressOffset variable will do that automatically. The READ command uses each label
to determine the EEPROM address where that string begins, and then adds the value of
the
addressOffset variable to know how many address numbers to shift over to find the
correct
DataItem. The DataItem found at the resulting Address will be stored in the
READ command's Variable argument. Notice that the Word modifier also comes before
the variable that stores the value fetched from EEPROM.
DO
READ Pulses_Count + addressOffset, Word pulseCount
READ Pulses_Left + addressOffset, Word pulseLeft
READ Pulses_Right + addressOffset, Word pulseRight
addressOffset = addressOffset + 2
' PBASIC code block omitted here.

Table of Contents

Other manuals for Parallax Boe-Bot

Questions and Answers:

Question and Answer IconNeed help?

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

Parallax Boe-Bot Specifications

General IconGeneral
BrandParallax
ModelBoe-Bot
CategoryRobotics
LanguageEnglish