login

Author Topic: Can not find reading slave addressed .......  (Read 1859 times)

0 Members and 1 Guest are viewing this topic.

Qynx

Can not find reading slave addressed .......
« on: November 12, 2012, 03:34:07 PM »
I've been searching but can not find it in the Wire library ...
I want to read a particular address in a slave.

with Wire.requestFrom (slave, bytes) I can read some bytes but not on a specific adress.

It's no problem for me to write this but I want for my sample programs as much as possible using standard libraries.

  Does anyone know if I've looked ok?


Rob Keij

barragan

Re: Can not find reading slave addressed .......
« Reply #1 on: November 13, 2012, 04:06:04 PM »
Please check the Wire library section for examples on this page: http://wiring.org.co/learning/libraries/
Let me know.

Qynx

Re: Can not find reading slave addressed .......
« Reply #2 on: November 13, 2012, 07:03:57 PM »

Ok, it's simple.......   Thanks


Code: [Select]

unsigned char readRegister(unsigned char r)
{
  unsigned char v;
  Wire.beginTransmission(I2C_ADDRESS);
  Wire.send(r);  // register to read
  Wire.endTransmission();

  Wire.requestFrom(I2C_ADDRESS, 1); // request a byte
  while(!Wire.available()); // wait until data available
  v = Wire.receive();
  return v;
}