login

Author Topic: Wire library (writer)arduino  (Read 1620 times)

0 Members and 1 Guest are viewing this topic.

baligh1979

Wire library (writer)arduino
« on: February 25, 2014, 01:15:59 AM »
my vertion in arduino 1.5.5.r2
what is wrong in code follow

#include <Wire.h>

void setup()
{
  Wire.begin(2);                 // join i2c bus with address #2
  Wire.onRequest(requestEvent);  // register event
}

void loop()
{
  delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
  Wire.write("hello ");  // respond with message of 6 bytes