# EEPROM Example

{PBASIC 1.0}

Syntax: EEPROM

    ' EEPROM.BS1
    ' This program stores a couple of text strings into EEPROM with the EEPROM
    ' directive and then sends them, one character at a time via the SEROUT
    ' command.  This is a good demonstration of how to save program space by
    ' storing large amounts of data in EEPROM directly, rather than embedding
    ' the data into SEROUT commands.

    ' {$STAMP BS1}
    ' {$PBASIC 1.0}

    SYMBOL  SOut            = 0             ' serial output

    SYMBOL  idx             = B2            ' Holds current location number
    SYMBOL  phrase          = B3
    SYMBOL  char            = B4            ' Holds current character to print

    Phrases:
      EEPROM ("Here is a long message that needs to be transmitted.", 13, 0)
      EEPROM ("Here is some more text to be transmitted.", 13, 0)

    Main:
      idx = 0
      FOR phrase = 1 TO 2                   ' select phrase
        GOSUB Print_It                      ' print the phrase
        PAUSE 3000                          ' Pause for 3 seconds
      NEXT
      END

    Print_It:
      READ idx, char                        ' get next character
      idx = idx + 1                         ' point to next EEPROM location
      IF char = 0 THEN Print_Done           ' if 0, we're done with this block
      SEROUT SOut, N2400, (char)            ' otherwise, transmit it
      'DEBUG #@char                         ' -- for demo with DEBUG (slower)
      GOTO Print_It

    Print_Done:
      RETURN                                ' return to caller

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012