Eagle-tree Microsensor I2C Interface Uživatelský manuál Strana 3

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 4
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 2
Copyright © 2009-2011 Eagle Tree Systems, LLC
http://www.eagletreesystems.com
i2c_restart(); // perform I2C restart
// select sensor in read mode
if (!i2c_write(| SENSOR_ADDRESS | I2C_READ_BIT)) {
// read two bytes of sensor data
data[0] = i2c_read(1);
data[1] = i2c_read(0);
reading = *((signed short *)(&data[0]));
}
}
}
i2c_stop();
Here is the pseudo code for accessing the G-Force sensors:
byte data[6];
signed short GX, GY, GZ;
i2c_start();
// select sensor in write mode
if (!(i2c_write(SENSOR_ADDRESS | I2C_WRITE_BIT))) {
// send "read data" command to sensor
if (!i2c_write(0x07)) {
i2c_restart(); // perform I2C restart
// select sensor in read mode
if (!i2c_write(| SENSOR_ADDRESS | I2C_READ_BIT)) {
// read 6 bytes of sensor data
data[0] = i2c_read(1);
data[1] = i2c_read(1);
data[2] = i2c_read(1);
data[3] = i2c_read(1);
data[4] = i2c_read(1);
data[5] = i2c_read(0);
Zobrazit stránku 2
1 2 3 4

Komentáře k této Příručce

Žádné komentáře