| Electronic Components Datasheet Search |
|
SRF08 Datasheet(PDF) 13 Page - List of Unclassifed Manufacturers |
|
|
|||||||||||||||||||||||||||||
SRF08 Datasheet(HTML) 13 Page - List of Unclassifed Manufacturers |
|
13 / 16 page ![]() Mechatronic Systems MechBot Sensor Overview, Page 13 of 16 '** ** '** I2C Routines for the BX-24 ** '** to demonstrate the use of multiple SRF08's ** '** ** '** Copyright 2002 - Devantech Ltd ** '** Commercial use of this software is prohibited ** '** Private and educational use only is permitted ** '** ** '** Written by Gerald Coe - February 2002 ** '** ** '*********************************************************** Const SCL As Byte = 14 ' I2C clock - choose any pins you wish for SCL and SDA Const SDA As Byte = 13 ' I2C data Const CmdReg As Byte = 0 ' SRF08 command register Const LdrReg As Byte = 1 ' Address of Light Sensor Register in SRF08 Const RangeReg As Byte = 2 ' Address of Range Register in SRF08 Const RangeCmd As Byte = 81 ' Ranging command - 80 for inches, 81 for cm, 82 for uS ' Note that SRF08's must have been previously set to these addresses Const Sonar1 As Byte = &He0 ' 1st SRF08 at I2C address 0Xe0 Const Sonar2 As Byte = &He2 ' 2nd SRF08 at I2C address 0Xe2 Dim I2cAck As Boolean ' Acknowledge flag Sub Main() Dim Ldr1 As Byte Dim Range1 As New UnsignedInteger Dim Ldr2 As Byte Dim Range2 As New UnsignedInteger Call PutPin(SCL, bxOutputHigh) Call PutPin(SDA, bxOutputHigh) Do ' 1st SRF08 Ranger Call I2cByteWrite(Sonar1, CmdReg, RangeCmd) ' Start Ranging in Cm Call Delay(0.07) ' 70mS wait for ranging to complete Ldr1 = I2cByteRead(Sonar1, LdrReg) ' Read light sensor Range1 = I2cWordRead(Sonar1, RangeReg) ' Read Range Register ' 2nd SRF08 Ranger Call I2cByteWrite(Sonar2, CmdReg, RangeCmd) ' Start Ranging in Cm Call Delay(0.07) ' 70mS wait for ranging to complete Ldr2 = I2cByteRead(Sonar2, LdrReg) ' Read light sensor Range2 = I2cWordRead(Sonar2, RangeReg) ' Read Range Register debug.Print "LDR1 = "; CStr(Ldr1); ", Range1 = "; CStr(Range1); _ " LDR2 = "; CStr(Ldr2); ", Range2 = "; CStr(Range2) Loop End Sub |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |