#include #define led_pin 8 byte own_address = 8; byte received; void setup() { // config led_pin as Output for driving an LED pinMode(led_pin, OUTPUT); digitalWrite(led_pin, HIGH); // config TinyWire library for I2C slave functionality TinyWire.begin( own_address ); // sets callback for the event of a slave receive TinyWire.onReceive( onI2CReceive ); } void loop() { } /* I2C Slave Receive Callback: Note that this function is called from an interrupt routine and shouldn't take long to execute */ void onI2CReceive(int howMany){ received = TinyWire.read(); if(received==100){ digitalWrite(led_pin, LOW); }else if(received==200){ digitalWrite(led_pin, HIGH); } }