AnsweredAssumed Answered

About I2C

Question asked by YuJ on Dec 6, 2012
Latest reply on Dec 6, 2012 by YuJ
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?

Outcomes