Telephone: +44 7814 044 754   Skype: warburtech

Add to Favourites

Instruction Set

The following gives a complete list of PBASIC commands for all versions of the BASIC Stamp. It does not include arithmetic or logical operators. Many enhancements were made to the PBASIC language with the release of the BASIC Stamp II and thus some commands only exist on one version of the BASIC Stamp. For more detailed information on the differences between PBASIC1 and PBASIC2, download the BASIC Stamp I to BASIC Stamp II Conversion document.
BASIC Stamp BS1-IC Indicates instruction is only available on the BASIC Stamp BS1-IC.
BASIC Stamp BS2-IC Indicates instruction is only available on the BASIC Stamp BS2-IC.
BASIC Stamp BS2E-IC Indicates instruction is only available on the BASIC Stamp BS2E-IC.
BASIC Stamp BS2SX-IC Indicates instruction is only available on the BASIC Stamp BS2SX-IC.
BASIC Stamp BS2P-IC Indicates instruction is only available on the BASIC Stamp BS2P24-IC.
BRANCHING
  IF . . .THEN Compare and conditionally branch.
  BRANCH Branch to address specified by offset.
  GOTO Branch to address.
  GOSUB Branch to subroutine at address.
  RETURN Return from subroutine.
RUN Switch to one of eight BS2SX-IC program banks.
POLLRUN Switch execution to another program page upon the occurrence of a polled interrupt.
LOOPING
  FOR . . . NEXT Establish a FOR - NEXT loop.
NUMERICS
LET Perform variable manipulation, such as A=5, B=A+2, etc. Possible operations are add, subtract, multiply, divide, max. limit, min. limit, and logical operations AND, OR, XOR, AND NOT, OR NOT, and XOR NOT.
  LOOKUP Lookup data specified by offset and store in variable. This instruction provides a means to make a lookup table.
  LOOKDOWN Find target's match number (0-N) and store in variable.
  RANDOM Generate a pseudo-random number.
DIGITAL I/O
  INPUT Make pin an input.
  OUTPUT Make pin an output.
  REVERSE If pin is an output, make it an input. If pin is an input, make it an output.
  LOW Make pin output low.
  HIGH Make pin output high.
  TOGGLE Make pin an output and toggle state.
  PULSIN Measure an input pulse.
  PULSOUT Output a timed pulse by inverting a pin for some time.
  BUTTON Debounce button, perform auto-repeat, and branch to address if button is in target state.
COUNT Count cycles on a pin for a given amount of time (0 to 125 kHz, assuming 50/50 duty cycle).
XOUT Generate X-10 powerline control codes. For use with X-10 lamp and appliance control modules.
POLLIN Specify pin and state for a polled-interrupt.
POLLOUT Specify pin and state for output upon a polled-interrupt.
POLLMODE Specifies the polled-interrupt mode.
ASYNCHRONOUS SERIAL I/O
  SERIN Serial input with optional qualifiers and variables for storage of received data. On the BS1-IC, baud rates of 300, 600, 1200, and 2400 are possible. On the BS2-IC, any baud rate (up to 50k baud) is possible. Also, the BS2-IC has a serial input time-out function.
  SEROUT Send data serially. On the BS1-IC, data is sent at 300, 600, 1200, or 2400 baud. On the BS2-IC, data is sent at any baud rate (up to 50k baud).
OWIN Input data from a 1-wire device.
OWOUT Output data from a 1-wire device.
SYNCHRONOUS SERIAL I/O
SHIFTIN Shift bits in from parallel-to-serial shift register.
SHIFTOUT Shift bits out to serial-to-parallel shift register.
I2CIN Input data in from I2C serial device.
I2COUT Output data out to I2C serial device.
PARALLEL I/O
LCDCMD Writes a command to an LCD.
LCDIN Reads data from an LCD.
LCDOUT Writes data to an LCD.
ANALOGUE I/O
  PWM Output PWM, then return pin to input. This can be used to output analogue voltages (0 to 5 V) using a capacitor and resistor.
POT Read a 5 to 50K potentiometer and scale result.
RCTIME Measure an RC charge/discharge time. Can be used to measure potentiometers (faster than POT on BS1-IC).
SOUND
SOUND Play notes. Note 0 is silence, notes 1 to 127 are ascending tones, and notes 128 to 255 are white noises.
FREQOUT Generate one or two sine waves of specified frequencies (each from 0 to 32767 Hz).
DTMFOUT Generate DTMF telephone tones.
EEPROM ACCESS
DATA Store data in EEPROM before downloading BASIC program (BS2-IC).
EEPROM Store data in EEPROM before downloading BASIC program (BS1-IC).
  READ Read EEPROM byte into variable.
  WRITE Write byte into EEPROM.
STORE Switch READ/WRITE access to different program slot.
RAM ACCESS
GET Read byte from BS2SX-IC scratch pad RAM.
PUT Store byte in BS2SX-IC scratch pad RAM.
TIME
  PAUSE Pause execution for 0 to 65536 milliseconds.
POLLWAIT Pause until a polled-interrupt occurs.
POWER CONTROL
  NAP Nap for a short period. Power consumption is reduced.
  SLEEP Sleep for 1 to 65535 seconds. Power consumption is reduced to 20 µA (BS1-IC) or 50 µA (BS2-IC).
  END Sleep until the power cycles or the PC connects. Power consumption is the same as SLEEP instruction.
PROGRAM DEBUGGING
  DEBUG Sends variables to PC for viewing.
Google
Cards PayPal
 


Visitor Counter

Page Updated:
27/04/08

Mastercard Visa Credit Solo Visa Debit JCB Visa Electron Maestro
Acceptance Mark

Telephone: +44 7814 044 754   Skype: warburtech

Warburton Technology, 33 Selkirk Close, Wimborne, Dorset, BH21 1TN, United Kingdom

VAT Registration Number: GB 846 917 877

Warburton Technology