Linked from: https://karma-laboratory.com/petridish/2005/02/working_progres_3.html.

'{$STAMP BS2sx}
'{$PBASIC 2.5}

'Author: Pearl Chen (pearl at karma-laboratory.com)
'Date: Feb 27, 2005


'***** PINS *****
'Columns (negative / anode) 1 through 8 are pins 0 through 7 respectively
'Rows (positive / cathode) A through H are pins 8 through 15


'***** CONSTANTS ******
P CON 30                       'Pause length for how long a column stays lit up


'***** VARIABLES *******
row     VAR        Word        'row will be a decimal number coming in from Processing
col     VAR        Word        'col will be used as a counter to turn on the pins 0-8


'***** INIT *******
DIRS = %1111111111111111       'Set the direction of all pins to output
OUTS = %0000000000000000       'Init all pins to LOW (off)


'***** MAIN FUNCTION ******

Main:

  FOR col=0 TO 7                'scan through columnn numbers

    HIGH col                    'turn on column

      SERIN 16, $f0, [row]      'get a decimal number from Processing via the serial port representing what rows to turn on
                                '    16: The pin number that is used for dedicated serial communications by the Basic Stamp Stack
                                '    $f0: The baudmode used (in hexadecimal format... in decimal it would be 240)
                                '         since Processing is sending the data at 9600 baud and it's a BS2sx
                                '    row: A decimal number representing what rows to turn on
                                '         (since I couldn't figure out how to send %10100110 or something similiar)

      OUTH = row                'what rows to turn on (note how I'm targeting pins 8-15 by using OUTH
      PAUSE P                   'give it some breathing room so it's actually visible
      OUTH = 0                  'turn off all the rows (I couldn't figure out how to invert the row so using 0 works)

    LOW col                     'turn off the column

    IF col=7 THEN col=-1        'when it reaches the last counter, reset col so it'll start back at 0

  NEXT

END


'***** SUBROUTINES *******
'none