Created
December 11, 2014 03:13
-
-
Save extrasleepy/580d8e8e2708a4b00478 to your computer and use it in GitHub Desktop.
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(1); //declare device address here | |
Wire.onReceive (beHappy); //acts as interrupt and executed function | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
delay(100); | |
} | |
void beHappy(int data){ //function expects one parameter | |
while(1 < Wire.available()) | |
{ | |
char c = Wire.read(); | |
Serial.print(c); | |
} | |
byte x = Wire.read(); | |
Serial.println(x); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment