Meine Fehler sind ja noch schlimmer - im R N Wiki steht ein Beispielprogramm für den SRF02 MIT der Sequenz Warteaufmessung (in Bascom) die wohl genau das tut, was ich eigentlich suche:
Code:'------------- Hilfsfunktionen für SRF02 ---------- Function Srf02_firmware(byval Slaveid As Byte) As Byte Local Firmware As Byte Local Slaveid_read As Byte slaveid_read = Slaveid + 1 I2cstart I2cwbyte Slaveid I2cwbyte 0 'Leseregister festlegen I2cstop I2cstart I2cwbyte Slaveid_read I2crbyte Firmware , Nack I2cstop Srf02_firmware = Firmware End Function Function Srf02_entfernung(byval Slaveid As Byte) As Integer Local Lob As Byte Local Hib As Byte Local Firmware As Byte Local Temp As Byte Local Slaveid_read As Byte slaveid_read = Slaveid + 1 'Messvorgang in starten I2cstart I2cwbyte Slaveid I2cwbyte 0 I2cwbyte 81 'in Zentimetern messen I2cstop Warteaufmessung: Waitms 1 Firmware = Srf02_firmware(slaveid) If Firmware = 255 Then Goto Warteaufmessung I2cstart I2cwbyte Slaveid I2cwbyte 2 'Leseregister festlegen I2cstop I2cstart I2cwbyte Slaveid_read I2crbyte Hib , Ack I2crbyte Lob , Nack I2cstop Srf02_entfernung = Makeint(lob , Hib) End Function End







Zitieren

Lesezeichen