Infrared Vision

Objective

Learn how to detect distances using the SHARP GP2D12 infrared distance detector, ADC0831 8-bit analog-to-digital converter, and Parallax's basic stamp module.

Code

GP2D12_ADC0831.bs2



Hardware

» SHARP GP2D12 infrared distance sensor (datasheet)
» ADC0831 8-bit analog/digital converter (datasheet)
» Parallax BS2/BOE
» PSC
» 10µF tantalum capacitor
» 1kΩ resistor
» 2kΩ resistor
» Jumper wires

Overview

The SHARP GP2D12 infrared distance detector produces analog voltage levels corresponding to object distances. The ADC0831 8-bit analog-to-digital converter reads the GP2D12 output voltage, compares the voltage to a reference voltage, and assigns an 8-bit value. Finally, the BS2 reads the 8-bit value into a program variable. The variable can be used in BS2 code to produce desired results like obstacle avoidance or simply displaying distance readings on the editorís debug screen.

Fig-1 Schematic
Infrared Vision Wiring Diagram
IR Vision Schematic

Fig-2 Connections
ADC083 to BS2/BOE and GP2D12 GP2D12 to BS2/BOE and ADC083
pin1(CS) BS2/BOE pin9 pin1(Vo) ADC0831 pin2 (Vin+ )
pin2(Vin+) GP2D12 (Vo) pin2(GND) BS2/BOE Vss (Ground)
pin3(Vin) BS2/BOE Vss (Ground) pin3(Vcc) BS2/BOE Vdd (+5V)
pin4(GND) BS2/BOE Vss (Ground)    
pin5(Vref) BS2/BOE Vdd (+5V) through the 1kΩ resistor (R1)    
pin5(Vref) BS2/BOE Vss (Ground) through the 1.5kΩ resistor (R2)    
pin6(Dout) BS2/BOE pin10    
pin7(CLK) BS2/BOE pin 11    
pin8(Vcc) BS2/BOE Vdd (+5V)    
pin8(Vcc) BS2/BOE Vss(Ground) through a 10µF capacitor