I am attempting to communicate between an Arduino and an AtTiny85 with I2C using the TinyWireS library. I only need the Arduino to send commands to the AtTiny, it does not need to talk back.
The Arduino is using the Wire library, and it works fine, however whenever I try to compile the AtTiny85 code, it gives the following error:
libraries\TinyWireS\TinyWireS.cpp.o (symbol from plugin): In function `usi_onReceiverPtr':
(.text+0x0): multiple definition of `usi_onReceiverPtr'
sketch\ATtiny_Servo.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\TinyWireS\TinyWireS.cpp.o (symbol from plugin): In function `usi_onReceiverPtr':
(.text+0x0): multiple definition of `usi_onRequestPtr'
sketch\ATtiny_Servo.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\TinyWireS\TinyWireS.cpp.o (symbol from plugin): In function `usi_onReceiverPtr':
(.text+0x0): multiple definition of `_onTwiDataRequest'
sketch\ATtiny_Servo.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board ATtiny25/45/85.
Here is my code:
#include <TinyWireS.h>
#include <usiTwiSlave.h>
#define output (4)
#define I2C_SLAVE_ADDR (1)
void setup() {
// put your setup code here, to run once:
TinyWireS.begin(I2C_SLAVE_ADDR);
pinMode(output, OUTPUT);
}
volatile byte msg = 0;
void loop() {
if(TinyWireS.available())
msg = TinyWireS.receive();
if(msg == 1)
digitalWrite(output, HIGH);
else if(msg == 0)
digitalWrite(output, LOW);
else
msg = 0;
}
#include <usiTwiSlave.h>
line? Also according to github.com/rambo/TinyWire/blob/master/TinyWireS/examples/… you have to defineI2C_SLAVE_ADDR
before you includeTinyWireS.h
. – Maximilian Gerhardt