' Reads an ADS7818 12-bit adc ' {$STAMP BS2} ' {$PBASIC 2.5} ' November 1, 2006 ' ' ADS7818 Pin 7 (clock) goes to BS2 Pin 2 ' ADS7818 Pin 6 (data) goes to BS2 Pin 1 ' ADS7818 Pin 5 (convert) goes to BS2 Pin 0 ' ' Define Inputs and Outputs OUTPUT 2 'clock pulse, normal low OUTPUT 0 'convert when goes low, normal high INPUT 1 'data in - read 13 bits due to wasted clock pulse ' ' Define Variables and Constants AdcBits VAR Word '12-Bit ADC result Junk VAR Word 'Wasted, used to complete clocking ' ' Begin Main Main: HIGH 0 'Start conversion bit high, serial out when it goes low LOW 0 SHIFTIN 1, 2, MSBPOST, [AdcBits\13,Junk\3] HIGH 0 DEBUG DEC ? AdcBits, CR GOTO Main STOP END