Nein es ist mehr so dass ich gar keine töne höre
Ich benutze zum größten teil das srf02 beispielCode:Declare Function Srf02_firmware(byval Slaveid As Byte) As Byte Declare Function Srf02_entfernung(byval Slaveid As Byte) As Integer $regfile = "m32def.dat" $framesize = 42 $swstack = 42 $hwstack = 42 $crystal = 16000000 'Quarzfrequenz $baud = 9600 Config Portb.2 = Output 'Portb.2 = 1 Config Scl = Portc.0 'Ports fuer IIC-Bus Config Sda = Portc.1 Const Srf02_slaveid = &HE0 'Standard I2C Adresse von SRF02 Dim Entfernung As Integer Dim V As Byte Wait 3 'Warte 3 Sekunden I2cinit V = 1 Do Select Case Entfernung Case 200 To 150 : Sound Portb.2 , 200 , 300 Case 150 To 100 : Sound Portb.2 , 200 , 400 Case 100 To 50 : Sound Portb.2 , 200 , 500 Case 50 To 10 : Sound Portb.2 , 200 , 600 End Select Wait 1 Loop End '------------- 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
und mit if und einer entfernung geht das aber nicht im case
und wenn ich
mache bekomme ich nur fehler meldungenCode:select case entfernung case etfernung <=100: Sound usw..







Zitieren

Lesezeichen