'{$STAMP BS2sx} '{$PBASIC 2.5} 'ANALOG IN AND OUT ' RCTime is the term used on the basic stamp for ' reading analog inputs despite the fact that a ' microcontroller only deals in digital units. ' The "RC" stands for Resistor-Capacitor. Since RCVar VAR WORD ' This variable will hold the result of the input. LEDout VAR WORD sendVar VAR BYTE Main: ' Take pin 14 high to discharge the capacitor in the circuit. HIGH 14 ' Hold for a millisecond to make sure the capacitor is discharged. PAUSE 1 ' Measure the time it takes to charge the capacitor again. RCTIME 14, 1, RCVar sendVar = RCVar / 4 ' Use DEBUG to view the result. 'DEBUG "RCVar: ", DEC sendVar, CR ' On the BS2SX, 1 unit = .8 microseconds. ' 1,000,000 microseconds = 1 second. LEDout = RCVar * 2 PULSOUT 8, LEDout ' Pause is measured in milliseconds. ' 1,000 milliseconds = 1 second. PAUSE 1 GOTO sendserial 'GOTO main sendserial: SEROUT 16, 1021, [sendVar] GOTO main