cancel
Showing results for 
Search instead for 
Did you mean: 

About I2C

s1170198
Associate II
Posted on December 06, 2012 at 11:27

Hi

I use STBee.

When I perform I2C in Arduino, I write such a code.

void writeDevice(byte address, byte registerAddress, byte data){

  Wire.beginTransmission(address); 

  Wire.write(registerAddress);    

  Wire.write(data);             

  Wire.endTransmission();    

}

byte readDevice(byte address, byte registerAddress){

  byte data = 0;

  Wire.beginTransmission(address);

  Wire.write(registerAddress);

  Wire.endTransmission();

  Wire.beginTransmission(address);

  Wire.requestFrom((char)address,1);

  if(Wire.available()){   

    data = Wire.read();

  }

  Wire.endTransmission();

  return data;

}

There is a question about a function of Wire.requestFrom of this cord.

It is a function to require 1 byte to a device.

When I want to use this function in STBee, how should I do it?
1 REPLY 1
s1170198
Associate II
Posted on December 06, 2012 at 11:52

I2C communicates with an acceleration sensor(ADXL345).