Haha Mit diesem Code geht's... :

Und warum gehts mit meinem Hardwarecode nicht?

Code:
$crystal = 16000000
$regfile = "m8def.dat"

$baud = 9600

Config Portb = Output
Config Portd = Output

Config Pinc.5 = Output
Config Pinc.4 = Output

Config Scl = Portc.5
Config Sda = Portc.4


'Config Servos = 7 , Servo1 = Portd.2 , Servo2 = Portd.3 , Servo3 = Portd.4 , Servo4 = Portd.5 , Servo5 = Portd.6 , Servo6 = Portd.7 , Servo7 = Portb.0 , Reload = 10       'Servos initialisieren...

Twsr = &B00000000                                           'Bits1+0=00: TWI-Vorteilung 1
Twbr = &H0C                                                 'IC2-Bitrate 400000Hz bei 16MHz
                'BitRate=AvrClock/(16+2*TWBR*4^TwiPrescale)

Declare Function Twistart() As Byte
Declare Function Twisend(byval Databyte As Byte) As Byte
Declare Function Twireceive(byref Databyte As Byte) As Byte
Declare Sub Twistop()

Dim Msb As Byte
Dim Lsb As Byte
Dim Entfernung As Word

Enable Interrupts



Wait 1

'Servo(1) = 200
'Servo(2) = 0

Do

Print "STARTING......."

I2cstart 'Messung auslösen
I2cwbyte 0 '0 Adresse für alle Bausteine (Broadcastadresse)
I2cwbyte 0 'Register 0 - Befehlsregister
I2cwbyte 81 'Befehl 81 - Messung in cm
I2cstop

Waitms 300                                                  'delay 65mS auf Ergebnis warten

I2cstart
I2cwbyte 224 'E0 Addresse vom 1. US
I2cwbyte 2 'Register 2 (+3) = 1. Entfernung

I2cstart
I2cwbyte 225 'Leseadresse (E1)
I2crbyte Msb , Ack 'Register 2 lesen
I2crbyte Lsb , Nack 'Register 3 lesen
I2cstop

Entfernung = Makeint(lsb , Msb)                             'Word als Ergebnis von 2 Bytes bauen

Print "Entfernung: " + Str(entfernung) ; "cm."
'Print "MSB: " + Str(msb)
'Print "LSB: " + Str(lsb)


Loop
Ganz liebe Grüße,
Tobi