I have connected arduino mega and arduino uno through I2C serial communication.
I want mega as the master and uno as the slave.
The master will control the uno with several instructions give by five push buttons. So, there will be more than one digital value that will write and send to drive slave.
Since I have been looking for the guide, there are most tutorials or some like that told only one variable that send from master to slave or vice versa. I can copy that and work it out. But for My chase, there is not any idea yet.
Yes of course I'm still beginer.
@Klaus_K, this is about I2C. We send variables, arrays and structs over I2C.
Even a simple checksum is almost never used. The I2C should work 100% reliable and if it does not, then the functions Wire.endTransmission() and Wire.requestFrom() will indicate a problem.
@nurekoprasetyo, you don't need a protocol. I think Klaus_K was half asleep or has been drinking.
It will be easier for us if you show your sketch for the Master and the Slave.
Only 5 pushbuttons ? Then you can use the 8 bits of a byte and transfer that single byte. Or you can use an array of 5 bytes.
Arduino has nice functions to select bits. They are bitRead() and bitWrite().
It was just a little innocent joke to see if you would bite
You seem to miss that this is about I2C.
This protocol is incomplete and could cause synchronization issues.
No, it does not. That is impossible. This is about I2C. Data is transferred in packages. The Wire library uses packages and clears the buffers before starting a new I2C session. https://www.i2c-bus.org/
For a start most newbies won't have a clue what a protocol is, or even what a library is.
Secondly I can't see why a newbie would be recommended to study the NMEA 0183 protocol when their question is about I2C. It's a bit like suggesting that a budding motor racing driver should learn sailboat racing.
It's also very unclear to me what is the OP's issue. Is it that he doesn't know how to send one of 5 different commands based on the button pressed(or one of 32 commands if simultaneous multiple buttons pressed) or how to make the slave switch activities based on those commands?