Last active
December 4, 2015 04:04
-
-
Save Corinrypkema/8300211b822c4e3567a5 to your computer and use it in GitHub Desktop.
I2C example from arduino with modifications for LightBlue(TM) testing
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> | |
byte val = 0; | |
void setup() { | |
Wire.begin(8); // join i2c bus with address #8 | |
Wire.onRequest(requestEvent); // register event | |
} | |
void loop() { | |
delay(1000); | |
val ^= 1 << 0; | |
} | |
// function that executes whenever data is requested by master | |
// this function is registered as an event, see setup() | |
void requestEvent() { | |
Wire.write(val); // respond with message of 1 bytes | |
// as expected by master | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment