Last active
April 9, 2016 11:14
-
-
Save aviosipov/a965bfc5ccd705e33922641a0090907a to your computer and use it in GitHub Desktop.
ardunio dual core - master
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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