Skip to content

Instantly share code, notes, and snippets.

@extrasleepy
Created December 11, 2014 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save extrasleepy/580d8e8e2708a4b00478 to your computer and use it in GitHub Desktop.
Save extrasleepy/580d8e8e2708a4b00478 to your computer and use it in GitHub Desktop.
#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