'{$STAMP BS2} '{$PBASIC 2.5} ' 2008 mlab.taik.fi/paja ' Sending data to Serial port ' ---[ I/O Definitions ]--- pPot PIN 10 pLED PIN 13 ' ---[ Variables ]--- wResult VAR WORD bDuty VAR BYTE ' ---[ Constants ]--- cBS2 CON $100 ' x 1.0, cycle adjustment (for ms) cCycle CON 50 'Required Charge time (Cycle equation) = 5 * Resistance * Capacity 'Charge time = 5 * 10KR(10000R) * 1µF(1/1000000F) = 0.05 seconds = 50ms ' ---[ Initialization ]--- DEBUG CLS, "Sending data to Serial port", CR ' ---[ Main Code ]--- Main: DO HIGH pPot ' charge the capacitor PAUSE 1 ' for 1 ms RCTIME pPot, 1, wResult ' measure RC discharge time DEBUG wResult/255 'Send raw data of integer, not ASCII code. PAUSE 100 LOOP END