Wiring Forum

All Forums => Website Questions => Topic started by: baligh1979 on February 25, 2014, 01:15:59 AM

Title: Wire library (writer)arduino
Post by: baligh1979 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