'{$STAMP BS2} 'read a photocell (or any other variable resistor) with RCTIME 'and report the result with SEROUT as a byte value (0 to 255) sInPin con 2 'serial in pin sOutPin con 3 'serial out pin rcPin con 8 'pin for rcTime rValue var word 'raw reading from RCTIME bValue var byte 'result scaled and limited to fit in a single byte bValuePrev var byte 'previous value top: pause 20 'pause between readings high rcPin 'set pin high pause 1 rctime rcPin,1,rValue 'read the pin bValue = rValue max 255 'limit result to a byte if bValue <> bValuePrev then report 'check if it's changed goto top report: bValuePrev = bValue 'record current value debug dec rValue, " ", dec bValue, cr serOut sOutPin,16390,[bValue] goto top 'These are the baudmode values for usable baud rates for the BS2: '16468 for 9600, 16416 for 19200, 16390 for 38400