Sharp GP2D12, ADC0831 and BS2
GP2D12 to ADC0831·to BS2 Schematic·
' Pin Assignments
CS····· CON·· 9·········· ' Chip Select
DIO_10· CON·· 10······ ' Data I/O pin 10
CLK···· CON·· 11······· ·' Clock
ADResult· VAR·· Byte·· ' Variable to hold 8-bit AD result.
HIGH CS··················· ' Deactivate ADC to begin.
Main:
· GOSUB Get_Average_AD_Reading·············· ' Get data from ADC.
· DEBUG CLS
· DEBUG "Raw 8-Bit data:· ",DEC ADResult,CR
· PAUSE 500································· ' Wait a half second.
GOTO Main··································· ' Endless loop.
Get_Average_AD_Reading:
··· LOW CS·································· ' Activate the ADC.
··· SHIFTIN DIO_10,CLK,MSBPOST,[noparse][[/noparse]ADResult\8]· ' Get data bits.
··· HIGH CS································· ' Deactivate the ADC.
RETURN
Post Edited (Mike Gebhard) : 7/31/2004 10:06:56 PM GMT
' Pin Assignments
CS····· CON·· 9·········· ' Chip Select
DIO_10· CON·· 10······ ' Data I/O pin 10
CLK···· CON·· 11······· ·' Clock
ADResult· VAR·· Byte·· ' Variable to hold 8-bit AD result.
HIGH CS··················· ' Deactivate ADC to begin.
Main:
· GOSUB Get_Average_AD_Reading·············· ' Get data from ADC.
· DEBUG CLS
· DEBUG "Raw 8-Bit data:· ",DEC ADResult,CR
· PAUSE 500································· ' Wait a half second.
GOTO Main··································· ' Endless loop.
Get_Average_AD_Reading:
··· LOW CS·································· ' Activate the ADC.
··· SHIFTIN DIO_10,CLK,MSBPOST,[noparse][[/noparse]ADResult\8]· ' Get data bits.
··· HIGH CS································· ' Deactivate the ADC.
RETURN
Post Edited (Mike Gebhard) : 7/31/2004 10:06:56 PM GMT