# WRITE Examples

Syntax: WRITE

    ' WRITE.BS1
    ' This program writes a few bytes to EEPROM and then reads them back out
    ' and displays them in the Debug window.

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

    SYMBOL  addr            = B2            ' address
    SYMBOL  value           = B3            ' value

    Main:
      WRITE 0, 100                          ' write some data to locations 0 - 3
      WRITE 1, 200
      WRITE 2, 45
      WRITE 3, 28

    Read_EE:
      FOR addr = 0 TO 3
        READ addr, value                    ' read value from address
        DEBUG #addr, ": ", #value, CR       ' display address and value
      NEXT
      END

NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.

    ' WRITE.BS2
    ' This program writes some data to EEPROM and then reads them back out
    ' and displays the data in the Debug window.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    idx             VAR     Byte            ' loop control
    value           VAR     Word(3)         ' value(s)

    Main:
      WRITE 0, 100                          ' single byte
      WRITE 1, Word 1250                    ' single word
      WRITE 3, 45, 90, Word 725             ' multi-value write

    Read_EE:
      FOR idx = 0 TO 6                      ' show raw bytes in EE
        READ idx, value
        DEBUG DEC1 idx, " : ", DEC value, CR
      NEXT
      DEBUG CR

      ' read values as stored

      READ 0, value
      DEBUG DEC value, CR
      READ 1, Word value
      DEBUG DEC value, CR
      READ 3, value(0), value(1), Word value(2)
      FOR idx = 0 TO 2
        DEBUG DEC value(idx), CR
      NEXT
      END

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012