Hey, I've got a quick question, does Wire.onRequest(event); work like an interrupt? I mean, is the function "event" executing immidiately after getting a request from I2C master?
If you would have the opportunity to program the ATmega328P/ATmega32A Microcontroller using assembly (low level language), you would certainly become impressed and astonished to observe how hard and beautiful work the Arduino Developers have done to bring the I2C Bus (aka TWI Bus) Protocol into the High Level Programming paradigm.
It is my understanding that the Forum Members who do talk on the I2C Bus have learnt the protocol having done a lot of experiments using two UNOs and many kinds of I2C based devices. They have also spent a good amount of time in the Forum particularly on the I2C Bus related topics.
Therefore, I would like to request you to kindly arrange the hardware (2 UNOs) and learn yourself (also by taking help from the Forum) (performing experiments) the meanins of TWI bus Interrupt, Wire.requestFrom();, Wire.onRequest();, Wire.onReceive();, Wire.available();, Wire.read();, Wire.write();, and etc.
The onRequest handler is a real interrupt function and it is called immediately.
The code of Wire.cpp and utility/twi.c work together. https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/libraries/Wire/src.
In twi.c is a single large interrupt routine that works almost like a state machine. It calls the onReceive and onRequest functions (via a pointer and via an other function) from that interrupt routine.
You don't need a delay in the Arduino loop(). You can use an empty loop().
However, in your sketch you probably need code in the loop().
Using the Serial functions (or delay or display functions or sensors via I2C) in a interrupt is not good. The Serial functions use interrupts themself, and things can get stuck with blocked interrupts.
Use volatile counters in interrupts, but do calculations and Serial things in the loop().
If you use an Arduino Uno, that is a 8-bit microcontroller. That means that when decay is read in the loop(), an interrupt could occur right in between reading the MSB and LSB of the delay variable.
The Wire.write() writes a byte, as @cattledog mentioned.