Hallo, um den Kompass auszulesen benutze ich folgenden Code:
Code:
int read_compass()
{
int data;
i2c_start(0xc0); // start the I2C bus
i2c_write(0xc1); // device address of the compass
i2c_write(1); // memory address first part
i2c_stop();
i2c_start(0xc1); // restart
data = i2c_readAck(); // read 1 byte
data += i2c_readNak(); // read 1 byte
i2c_stop(); // stopp
return data; // return the number of direction
}
Der war ja schon weiter oben zu sehen, und damit das ganze noch funktioniert, musst du die TWI.h (avr/include) und die twi_cmps.h/.c einbinden. (googlen oder mal ne Mail an mich, hab den Link leider nicht mehr)... so und dann sollte es funktionieren ....
Viel Erfolg!!!
Lesezeichen