Specifications

BASIC Stamp II
Page 302 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
Read
READ
location,variable
Read EEPROM location and store value in variable.
Location
is a variable/constant (0–2047) that specifies the
EEPROM address to read from.
Variable
holds the byte value read from the EEPROM (0–255).
Explanation
The EEPROM is used for both program storage (which builds down-
ward from address 2047) and data storage (which builds upward from
address 0). The Read instruction retrieves a byte of data from any
EEPROM address. Although it’s unlikely that you would want to read
the compressed tokens that make up your PBASIC2 program, storing
and retrieving long-term data in EEPROM is a very handy capability.
Data stored in EEPROM is not lost when the power is removed.
The demo program below uses the Data directive to preload the
EEPROM with a message; see the section BS2 EEPROM Data Storage
for a complete explanation of Data. Programs may also write to the
EEPROM; see Write.
Demo Program
This program reads a string of data stored in EEPROM. The EEPROM
data is downloaded to the BS2 at compile-time (immediately after you
press ALT-R) and remains there until overwritten—even with the power
off.
' Put ASCII characters into EEPROM, followed by 0,
' which will serve as the end-of-message marker.
Message data "BS2 EEPROM Storage!",0
strAddr var word
char var byte
strAddr = Message ' Set address to start of Message.
stringOut:
READ StrAddr,char ' Get a byte from EEPROM.
if char <> 0 then cont ' Not end? Continue.
Stop 'Stop here when done.