Shop OBEX P1 Docs P2 Docs Learn Events
Sharp GP2D12, ADC0831 and BS2 — Parallax Forums

Sharp GP2D12, ADC0831 and BS2

Mike GMike G Posts: 2,702
edited 2004-07-31 21:24 in Robotics
GP2D12 to ADC0831·to BS2 Schematic·
adc0831_IR_Schematic.gif

' 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
Sign In or Register to comment.