// Include the required Wire library for I2C
#include const int ledPin = 8; // the number of the LED pin const int i2c_address = 9; // define address of this slave for I2C // Initialize counter variables int counter = 0; void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // Start the I2C Bus as Slave on specified address Wire.begin(i2c_address); // Attach a function to trigger when something is received. Wire.onReceive(receiveEvent); } void receiveEvent(int bytes) { counter = Wire.read(); // read one character from the I2C for (int i = 0; i < counter; i++){ digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level) delay(150); // wait for a second digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW delay(150); // wait for a second } } void loop() { }