Reference.WireRead History

Hide minor edits - Show changes to markup

November 04, 2011, at 06:08 PM by Scott Fitzgerald -
Changed lines 7-8 from:

Reads a byte that was transmitted from a slave device to a master after a call to requestFrom() or was transmitted from a master to a slave.

to:

Reads a byte that was transmitted from a slave device to a master after a call to requestFrom() or was transmitted from a master to a slave. read() inherits from the Stream utility class.

Changed lines 47-48 from:
to:
October 31, 2011, at 02:47 PM by Tom Igoe -
Changed line 37 from:
    Serial.print(c);        // print the character
to:
    Serial.print(c);         // print the character
October 31, 2011, at 02:46 PM by Tom Igoe -
Changed line 37 from:
    Serial.print(c);          // print the character
to:
    Serial.print(c);        // print the character
October 31, 2011, at 02:46 PM by Tom Igoe -
Changed line 37 from:
    Serial.print(c);            // print the character
to:
    Serial.print(c);          // print the character
October 31, 2011, at 02:46 PM by Tom Igoe -
Changed line 34 from:
  while(Wire.available())     // slave may send less than requested
to:
  while(Wire.available())    // slave may send less than requested
Changed lines 36-37 from:
    char c = Wire.read();     // receive a byte as character
    Serial.print(c);               // print the character
to:
    char c = Wire.read();    // receive a byte as character
    Serial.print(c);            // print the character
October 31, 2011, at 02:46 PM by Tom Igoe -
Changed line 34 from:
  while(Wire.available())       // slave may send less than requested
to:
  while(Wire.available())     // slave may send less than requested
Changed lines 36-37 from:
    char c = Wire.read();       // receive a byte as character
    Serial.print(c);                 // print the character
to:
    char c = Wire.read();     // receive a byte as character
    Serial.print(c);               // print the character
October 31, 2011, at 02:46 PM by Tom Igoe -
Changed line 21 from:

[@

to:
Changed line 34 from:
  while(Wire.available())    // slave may send less than requested
to:
  while(Wire.available())       // slave may send less than requested
Changed lines 36-37 from:
    char c = Wire.read(); // receive a byte as character
    Serial.print(c);         // print the character
to:
    char c = Wire.read();       // receive a byte as character
    Serial.print(c);                 // print the character
Changed lines 42-43 from:

@]

to:
October 28, 2011, at 11:06 PM by Scott Fitzgerald -
Added lines 1-47:

Wire

read()

Description

Reads a byte that was transmitted from a slave device to a master after a call to requestFrom() or was transmitted from a master to a slave.

Syntax

Wire.read()

Parameters

none

Returns

The next byte received

Example

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop()
{
  Wire.requestFrom(2, 6);    // request 6 bytes from slave device #2

  while(Wire.available())    // slave may send less than requested
  { 
    char c = Wire.read(); // receive a byte as character
    Serial.print(c);         // print the character
  }

  delay(500);
}

See also

Share