BASIC Commands for the BASIC Stamp and BS1-IC (January 28, 1995) BRANCHING IF...THEN Compare and conditionally branch. BRANCH Branch to address specified by offset. GOTO Branch to address. GOSUB Branch to subroutine at address. Up to 16 GOSUBs are allowed. RETURN Return from subroutine. 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 OUTPUT Make pin an output. LOW Make pin output low. HIGH Make pin output high. TOGGLE Make pin an output and toggle state. PULSOUT Output a timed pulse by inverting a pin for some time. INPUT Make pin an input PULSIN Measure an input pulse. REVERSE If pin is an output, make it an input. If pin is an input, make it an output. BUTTON Debounce button, perform auto-repeat, and branch to address if button is in target state. SERIAL I/O SERIN Serial input with optional qualifiers and variables for storage of received data. If qualifiers are given, then the instruction will wait until they are received before filling variables or continuing to the next instruction. Baud rates of 300, 600, 1200, and 2400 are possible. Data received must be with no parity, 8 data bits, and 1 stop bit. SEROUT Send data serially. Data is sent at 300, 600, 1200, or 2400 baud, with no parity, 8 data bits, and 1 stop bit. ANALOG I/O PWM Output PWM, then return pin to input. This can be used to output analog voltages (0-5V) using a capacitor and resistor. POT Read a 5-50K potentiometer and scale result. SOUND SOUND Play notes. Note 0 is silence, notes 1-127 are ascending tones, and notes 128-255 are white noises. EEPROM ACCESS EEPROM Store data in EEPROM before downloading BASIC program. READ Read EEPROM byte into variable. WRITE Write byte into EEPROM. TIME PAUSE Pause execution for 0-65536 milliseconds. POWER CONTROL NAP Nap for a short period. Power consumption is reduced. SLEEP Sleep for 1-65535 seconds. Power consumption is reduced to approximately 20 uA. END Sleep until the power cycles or the PC connects. Power consumption is reduced to approximately 20 uA. DEBUGGING DEBUG Send variables to PC for viewing.