can you help me with I2C Sending then Receiving back from the slave.
When i send 'H' or 'L' through Serial monitor, the slave will read, if it receive's 'H' from the Master then it will reply to the master "Success" and if it's 'L' then the slave will reply again "fail"
Do you know what these do? If not, it's time that you did some research.
I2C communication is all about interrupts. An interrupt happens, on the slave, when the master sends data. You've registered a function, receiveEvent (not exactly a meaningful or novel name), to be called when that happens.
An interrupt happens, on the slave, when the master sends a request for data. You registered a function, requestEvent (not exactly a meaningful or novel name), to be called when that happens.
You've implemented the function receiveEvent() that actually gets called when the master sends data, though it does nothing useful.
You have not implemented the function requestEvent that actually gets called when the master requests data. So, of course, nothing happens.
The proper way would be to have a global variable that the receiveEvent() writes to, and then implement the requestEvent() function, and have it send a response based on what was in the global variable.
But, if you are happy with your limited understanding of I2C, I'm fine with that.
Can you provide a simple code structure that uses a global variable in a way that you suggested? I am new to programming as well, and am interested in learning about I2C communication.