We programmed our board with those codes.
Master Code
See
Dario documentation for more info about it.
#include <SoftwareSerial.h>
#include <TinyWireM.h>
#include <USI_TWI_Master.h>
SoftwareSerial darioSerial(0,1);
void setup(){
darioSerial.begin(9600);
TinyWireM.begin();
delay (300);
}
void loop(){
darioSerial.println("Hey I want to communicate");
TinyWireM.requestFrom(8,1);
while (TinyWireM.available()) {
int m = TinyWireM.receive(); //m is for "message"
darioSerial.println(m);
}
delay (600);
}
Slave Code
In this case,
Antonio wrote a new code to interface his slave board to Dario's one. He used the
TinyWireS library made by nadavmatalon (
GitHub).
#include <TinyWireS.h>
int LEDPin = 4;
void setup() {
pinMode(LEDPin, OUTPUT);
digitalWrite(LEDPin, HIGH);
TinyWireS.begin(8);
TinyWireS.onRequest(RapidBlink);
}
void loop(){
TinyWireS_stop_check();
}
void RapidBlink() {
TinyWireS.write(0);
for (short i = 0; i < 5; i++) {
digitalWrite(LEDPin, HIGH);
delay(50);
digitalWrite(LEDPin, LOW);
delay(50);
}
}