I keep receiving the following error in myATTiny85-Slave code below:
sketch_mar12a.ino: In function 'void setup()':
sketch_mar12a:19: error: 'class USI_TWI_S' has no member named 'onRequest'
I have downloaded TinyWireS and TinyWireS.h clearly has a public function onRequest. I opened the .ZIP file (downloaded from https://github.com/rambo/TinyWire) and drag-dropped TinyWireS folder into the Arduino libraries folder. This is how I install ALL libraries.
I am using Arduino 1.0.6
What am I doing wrong?
ATTiny85-Slave Code:
#include "TinyWireS.h" // wrapper class for I2C slave routines
#define I2C_SLAVE_ADDR 0x26 // i2c slave address (38)
byte t=10;
void setup()
{
TinyWireS.begin(I2C_SLAVE_ADDR); // init I2C Slave mode
TinyWireS.onRequest(requestEvent);
}
void loop()
{
}
void requestEvent()
{
TinyWireS.send(t);
}
Arduino Uno-Master Code:
#include <Wire.h>
#define I2C_SLAVE_ADDR 0x26 // i2c slave address (38)
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
byte num;
// read 1 byte, from address 0x26
Wire.requestFrom(I2C_SLAVE_ADDR, 1);
while(Wire.available()) {
num = Wire.read();
}
Serial.print("num = ");
Serial.println(num,DEC);
}