Hallo,

kleiner Tip: Declariere alle Kurse als byte und frage auch den Kompass entsprechend ab. Höhere Genauigkeit bringt eh nichts.

Also z.B.

Dim Kurs As Byte , Kursdif As Byte , Kurssoll As Byte
Declare Function Kompass() As Byte

Function Kompass() As Byte
I2cstart
I2cwbyte &HC0
I2cwbyte 1
I2cstop
I2cstart
I2cwbyte &HC1
I2crbyte Kompass , Nack
I2cstop
End Function



Alle Operationen wie z.B.
Kursdif=Kurs-Kurssoll

sind dann immer richtig, auch wenn der Robo durch N dreht, da alle Operationen modulo 256 sind.

Gruß

Christian H