'{$STAMP BS2p} '*********************************************************** '** ** '** I2C Routines for the Basic Stamp BS2p RevC or later ** '** with the SRF08, SRF10 and SRF235 Ultrasonic Rangers ** '** ** '** Copyright 2005 - Devantech Ltd ** '** Commercial use of this software is prohibited ** '** Private and educational use only is permitted ** '** ** '** Written by Gerald Coe - February 2005 ** '** ** '*********************************************************** ' Connect P8 (pin13) of the BS2p to the SRFxx SDA ' Connect P9 (pin14) of the BS2p to the SRFxx SCL ' Use 4k7 pull-up resistors from SCL and SDA to 5v supply SDA CON 8 ' SDA on pin13, SCL on pin14 Ver VAR Byte Light VAR Byte Range VAR Word ' range Loop: I2COUT SDA, $e0, 0, [81] ' Rangeing command - 80 for inches, 81 for cm, 82 for uS PAUSE 100 I2CIN SDA, $e1, 0, [Ver, Light, Range.HIGHBYTE, Range.LOWBYTE] DEBUG 2,0,1, "BS2p to SRF08, SRF10 or SRF235 " DEBUG 2,0,3, "Firmware Version ", DEC Ver, " " DEBUG 2,0,4, "Light Sensor ", DEC Light, " (SRF08 only, Reads 128 on the others) " DEBUG 2,0,5, "Range ", DEC Range," cm " GOTO Loop