I'm trying to use the TinyWire library for I2C communication between a master ATTiny85 and a slave ATTiny85. Either master or slave as the sender is fine, but I have not been able to get a basic transmission working. I am using the Arduino IDE to program the ATTinys. The code I am testing should turn on the LED if the communication is a success. Please advise me. Thanks!
//Master Receiver
#include <TinyWire.h>
const int ledPin = 3;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
TinyWire.begin();
}
void loop() {
TinyWire.requestFrom(10, 1);
bool receive = TinyWire.read();
if (receive == 1) {
digitalWrite(ledPin, LOW);
}
}
//Slave Sender
#include <TinyWire.h>
void setup() {
TinyWire.begin(10);
TinyWire.onRequest(onRequestI2C);
}
void loop() {
}
void onRequestI2C() {
TinyWire.send(1);
}
Also posted here.