Instantly share code, notes, and snippets.

@aviosipov /Slave
Last active Apr 9, 2016

Embed
What would you like to do?
ardunio dual core - master
#include <Wire.h>
void setup() {
Wire.begin();
}
void sendWireData(short data) {
Wire.beginTransmission(8); // transmit to device #8
Wire.write(data); // sends one byte
Wire.endTransmission(); // stop transmitting
}
void loop() {
sendWireData(1) ;
delay(500);
sendWireData(0);
delay(500) ;
}
#define LED_PIN 3
#include <Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
}
void loop() {
}
void receiveEvent(int howMany) {
char c = Wire.read();
if (c == 1 ) {
digitalWrite(LED_PIN,1) ;
} else if (c == 0) {
digitalWrite(LED_PIN,0) ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment